我的愿望输出是,如果“rolling.log”文件是在26-06-2012,第二天(27-06-2012)创建和修改的,那么该文件应该用“rolling-26-06-2012..log”重命名。 。现在输出是“rolling-27-06-2012.log”文件。
以下是我在web.config文件中的当前日志记录设置。
< * loggingConfiguration name =“”tracingEnabled =“true”defaultCategory =“myTestLog”>
<*listeners>
<*add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="C:\Project\Others\Testing\testMSLogging\rolling.log"
formatter="Text Formatter" rollFileExistsBehavior="Increment"
rollInterval="Minute" rollSizeKB="50" timeStampPattern="yyMMdd"
filter="Information" />
<*add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="C:\Project\Others\Testing\testMSLogging\testMSLogging\trace.log"
formatter="Text Formatter" filter="Error" />
</listeners>
<*formatters>
<*add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
template="Timestamp: {timestamp}{newline}
Message: {message}{newline}
Category: {category}{newline}
Priority: {priority}{newline}
EventId: {eventid}{newline}
Severity: {severity}{newline}
Title:{title}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Thread Name: {threadName}{newline}
Win32 ThreadId:{win32ThreadId}{newline}
Extended Properties: {dictionary({key} - {value}{newline})}"
name="Text Formatter" />
</formatters>
<*categorySources>
<*add switchValue="All" name="myTestLog">
<*listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</add>
</categorySources>
<*specialSources>
<*allEvents switchValue="All" name="All Events" />
<*notProcessed switchValue="All" name="Unprocessed Category" />
<*errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Flat File Trace Listener" />
</listeners>
</errors>
</specialSources>
请有人帮助我。非常感谢。
答案 0 :(得分:0)
不幸的是,这是它在企业库中的工作方式。其默认平面文件滚动背后的理念是它记录FILE.LOG中的所有输出,当滚动事件发生时,它将其重命名为FILE-ROLL-NAME.LOG并创建一个新的FILE.LOG 如果您需要不同的行为,您可能需要创建自己的日志记录跟踪侦听器或使用其他工具,如log4net。