Open log file (log4net) with multiline messages

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

Open log file (log4net) with multiline messages

Anthony Brenelière
Hello,

I have to read log4net files that have multi line messages.

Is there a specific pattern for that ? Or an option ?

Here is an example with a log4net pattern %d{HH:mm:ss} %p %logger %t %m:

10:01:26,926 DEBUG erviceM1Intervention 68  {
  "Origine": "TraitementAlarme",
  "TypeFiche": "Intervention",
  "IsInProgress": true,
  "Id": 1240394,
  "Etat": "Close",
  "Operateur": "Abreneli"

The first line matches the pattern but only '{' is added as message. Not following lines.

As the next line does not match the patters, its content should be added to the previous line message.

Is there a way to achieve this with log4view ?

Thank you for support

Reply | Threaded
Open this post in threaded view
|

Re: Open log file (log4net) with multiline messages

Philipp Lauchner
Administrator
Dear Anthony

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)

- Remove newlines in your output when logging: https://stackoverflow.com/questions/19993416/how-to-escape-newline-characters-in-the-message?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

- Add a specific identifier to the start of your pattern, e.g.: #MessageStart# %d{HH:mm:ss} %p %logger %t %m


Yours sincerely

Philipp Lauchner
PROSA GmbH  
Development & Support