Log to rolling CSV file with Enterprise Library
- by Tinminator
Need logging to:
Rolling file, to avoid 1 big log file.
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?