Enterprise Library 5 logging: Why this simple TextFormatter surrounds log entries with dashed?

156 Views Asked by At

Using Enterprise Library 5 logging. I have a simple text TextFormatter that supposed to produce CSV files as below:

<formatters>
  <add template="{timestamp(MM/dd/yyyy HH:mm:ss.fff)},{message}" 
        type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
        name="CommaSeparated" />
</formatters>

The problem is that the log entries in the text file always surrounded by dashes like below:

----------------------------------------
09/02/2015 20:12:01.591,message 1
----------------------------------------
----------------------------------------
09/02/2015 20:12:01.591,message 2
----------------------------------------
----------------------------------------
09/02/2015 20:12:01.591,message 3
----------------------------------------
----------------------------------------
09/02/2015 20:17:02.028,message 4
----------------------------------------
----------------------------------------
09/02/2015 20:17:02.028,message 5
----------------------------------------
----------------------------------------
09/02/2015 20:17:02.028,message 6
----------------------------------------

Where the dashes are coming from? How do I eliminate them? I just need a pure CSV format.

Any help would be appreciated.

1

There are 1 best solutions below

0
Randy Levy On

The default header and foot values (if not specified) for file based trace listeners are ---------------------------------------- which is why you are seeing them in the log file. It's actually not related to the formatter but the TraceListener. To not use the dashes just set the header and footer to be empty string:

<add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    fileName="trace.log" header="" footer="" />