Log to rolling CSV file with Enterprise Library

Posted by Tinminator on Stack Overflow See other posts from Stack Overflow or by Tinminator
Published on 2010-05-07T01:39:47Z Indexed on 2010/05/07 1:48 UTC
Read the original article Hit count: 389

Filed under:
|
|

Need logging to:

  1. Rolling file, to avoid 1 big log file.
  2. CSV format for easier look up.

I can see EntLib (5.0) have Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener to log to rolling log file.

To make the log entries look like a CSV row, I can change the Logging.Formatters.TextFormatter.Template to put double quote around the values. Also change the Listener's Footer and Header to nothing, so they won't be output.

Under normal circumstance, this would give me a well formed CSV file. However if a token value in the Template contain double quote, this would not be escaped, hence the log file become an invalid CSV file.

Is there any way to resolve this?

Is there any alternative solutions to this problem?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about EntLib