Formatting Log File Messages

Posted by Kumar on Stack Overflow See other posts from Stack Overflow or by Kumar
Published on 2010-03-11T14:37:07Z Indexed on 2010/03/11 19:24 UTC
Read the original article Hit count: 258

Filed under:
|
|

This is about formatting the messages for logging so as to subsequently be able to parse them relatively easily esp. given the extensive logging required in financial apps

Typically a line in the log file is of the form

TimeStamp: Module/Function:

where the log string contains whatever you choose, typically you'd have some key=value paradigm or even johnny5 key {value} etc.

A regex search through the log file might easily pick up Module/Function but enforcing and maintaing consistency on the log string itself for every developer on the team is often a pain

The logging api's are typically

ILog.LogInfo(string text, params object[] args)
ILog.LogWarning(string text, params object[] args)
ILog.LogError(string text, params object[] args)

Looking for opinions on better logging api's to format the log messages where a regex search can be performed for Module/Function = Basket/AddItem TokenA = Value1 and TokenB = Value2 etc. without going over every developer's every logging call

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#