Control Characters when logging to a text file

Topics: Logging Application Block
Apr 29, 2011 at 3:55 PM

Hi there,

One of the modules that is logging through my application (and on which I have no control at all, kind of like a third party pluggin) sends line breaks in its messages to the logger, which I need to escape in order to have every line in the log starting with the expected information for parsing. Is there a way to tell Enterprise Library to preserve control characters like line feed or carriage return when writing to a text file, or will I need to do the escaping myself?


May 2, 2011 at 6:27 AM


If I understood your question correctly, you want to log the message as:

Message: FirstLine\r\nSecondLine

instead of

Message: FirstLine

I'm not aware of any properties that will achieve this. The only way I think is to create a Custom Log Message Formatter, override the Format method then escape the control characters there.


Noel Angelo Bolasoc
Global Technologies and Solutions
Avanade, Inc.