Registration in the enterprise library - removing a hyphen from the format

I am using the Enterprise Library logging block in an ASP.NET MVC application. When I write a log message in a text file, it always adds 2 hyphen lines before and after the message:

---------------------------------------- [18/11/2013 03:20:53 pm] Update - jcardozo - Record updated ---------------------------------------- 

This is the formatter I use:

 <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="[{timestamp}] {keyvalue(action)} - {keyvalue(user)} - {message}" name="Text Formatter" /> 

How to remove these hyphen lines?

+6
source share
1 answer

In fact, these are the default properties for the trace listener (I assume that you are using a flat file trace listener or a Rolling Flat Trace trace listener). Properties can be set using the header and footer attributes in the configuration file. However, since they are not installed and the default values ​​are used, they will not actually be displayed in the configuration file (but they will be in the configuration tool).

So, if you do not want the header and footer to set them to empty. In the configuration file, it will look like this:

 <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="" /> 
+7
source

Source: https://habr.com/ru/post/958319/


All Articles