generate logs based on date using logging application block for EL 5.0?

拜拜、爱过 提交于 2019-12-24 11:29:23

问题


I am using logging application block for EL 5.0. I defined listener like below.

    <add name="FlatFile TraceListener" type="Microsoft.Practices.EnterpriseLibrary.
Logging.TraceListeners.FlatFileTraceListener, 
Microsoft.Practices.EnterpriseLibrary.Logging"              
listenerDataType="Microsoft.Practices.EnterpriseLibrary.
    Logging.Configuration.FlatFileTraceListenerData, 
Microsoft.Practices.EnterpriseLibrary.Logging"
        fileName="C:\Temp\RssLog.log" header="--------------"
        footer="----------------------" formatter="Brief Format Text"
                      traceOutputOptions="None" filter="All" />

How can generate log file daily?. like today=Rsslog10182011.log tomorrow = Rsslog10182011.log?


回答1:


If you use a rolling flat file trace listener that will give you a file for each day. This is from EL 4.1 but it is the same for EL5.

        <add fileName=".\Logs\exception.log" footer="" formatter="Trace Formatter" header="" rollFileExistsBehavior="Overwrite" rollInterval="Midnight" rollSizeKB="0" timeStampPattern="yyyyMMdd" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="Callstack" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Exception TraceListener"/>



回答2:


Try using the Rolling Flat File Trace Listener instead. For example you could try this for starters:

<add name="Rolling Flat File Trace Listener" 
     type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
     listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
     fileName="RssLog.log" 
     rollFileExistsBehavior="Increment" 
     rollInterval="Midnight" />

You can download the Enterprise Library 5.0 documentation for more details on configuring the Rolling Flat File Trace Listener.



来源:https://stackoverflow.com/questions/7812724/generate-logs-based-on-date-using-logging-application-block-for-el-5-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!