nultiline message log4net pattern

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
eli
Reply | Threaded
Open this post in threaded view
|

nultiline message log4net pattern

eli
I can't seem to figure out what type of log4net pattern I can give it so that it picks up messages with newline characters. My current pattern is
%-5level | %date{ABSOLUTE} | %-4thread | %30.30logger | %message%newline
problem is for messages that contain newlines only the firs line is read (until it hits the first %newline). I've tried setting the layout pattern in log4view to exclude the newline
%-5level | %date{ABSOLUTE} | %-4thread | %30.30logger | %message
but that doesn't help. What pattern can I give log4view so that it consumes everything up to the next log entry into the message?
Ideally I would like a pattern I can give log4view without having to modify the actual log4net output pattern. If that's not possible, the next best thing would be the least intrusive change to the log4net pattern (double trailing newline wouldn't work, since for all logs it will skip a line). Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: nultiline message log4net pattern

Philipp Lauchner
Administrator
Dear eli,

unfortunatelly this is a known problem of pattern based messages. You can find a discussion of that problem in this thread:
http://forum.log4view.com/NLog-multiline-Log-Message-tp245.html

To sum up, the possible solutions are:

- Use the xml layout (highly recommended by us)

- Use a layout renderer to remove newlines within your message when logging them: https://github.com/NLog/NLog/wiki/Replace-NewLines-Layout-Renderer

- Add a specific identifier to the start of your pattern, e.g.: #MessageStart# %-5level | %date{ABSOLUTE} | %-4thread | %30.30logger | %message%newline


Yours sincerely

Philipp Lauchner
PROSA GmbH  
Development & Support