views:

36

answers:

1

Hi everyone, im using Enterprise Library Logging Block for tracing messages in my application, and i want to write messages with the following templates, in the same log file:

MESSAGE TEMPLATE 1:
Timestamp: {timestamp}
MessageType: {severity}
Message: {message}
appID: {keyvalue(Username)}

MESSAGE TEMPLATE 2:
Timestamp: {timestamp}
MessageType: {severity}
Message: {message}
Stacktrace:{keyvalue(Stacktrace)}
appID: {keyvalue(Username)}
Module: {keyvalue(Module)}

For it i use the following code:

LogEntry logEntry = new LogEntry();
logEntry.Message = message;
...
Logger.Write(logEntry);

However this writes messages with the TEMPLATE 1, and i would like to define what template im using before writting to the file...

Anyone as clues about the best way to do this?

Thanks in advance

A: 

I suggest you reading this post:

David Hayden Blog

Old one...but nice example.

bastianneu