C# 4.0, Microsoft Practices Enterprise Library 5.0
When you implement a Microsoft Practices Enterprise Library Logging, maybe you could need to distinguish the file logging by date and for to do this you can follow these traces.
When you implement a Microsoft Practices Enterprise Library Logging, maybe you could need to distinguish the file logging by date and for to do this you can follow these traces.
1. Open the configuration file (like
app.config) and search the “listeners”
element near “loggingConfiguration”,
set the “add”
element’s attribute “fileName”
in this way.
<add fileName="C:\Project\logs\Project.log"
header="----------------------------------------"
footer="----------------------------------------"
formatter="Text Formatter"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="DateTime"
filter="All"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="RollingFile
TraceListener" rollFileExistsBehavior="Increment"
rollInterval="Day" rollSizeKB="0"
timeStampPattern="yyyy-MM-dd"/>
2. Search the “listeners” element near “categorySources”, set
the “add” element’s
attribute “name” to
“RollingFile
TraceListener”.
<add name="RollingFile
TraceListener"/>
3. Search the “listeners” element near “specialSources”, set the
“add” element’s
attribute “name” to
“RollingFile
TraceListener”.
<add name="RollingFile TraceListener"/>
In this way
you obtain a log file similar this:
Project.2012-08-20.1.log
Nessun commento:
Posta un commento