C# EL 5.0切换日志记录开/关
我正在使用enterprise library 5.0进行日志记录,我不知道如何关闭日志记录。目前,它已打开并正常工作 这是关于日志的web.config部分,它是使用EL5.0GUI自动创建的C# EL 5.0切换日志记录开/关,c#,asp.net,logging,enterprise-library,C#,Asp.net,Logging,Enterprise Library,我正在使用enterprise library 5.0进行日志记录,我不知道如何关闭日志记录。目前,它已打开并正常工作 这是关于日志的web.config部分,它是使用EL5.0GUI自动创建的 <loggingConfiguration name="" tracingEnabled="true" defaultCategory="Logging Only"> <listeners> <add name="Flat File Trace List
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="Logging Only">
<listeners>
<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=..."
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=..."
fileName="WMSlog.log" formatter="Text Formatter" />
<add enabled="false" name="Formatted EventLog TraceListener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=..."
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=..."
source="Exception Handling" formatter="Text Formatter" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=..."
template="Timestamp: {timestamp}{newline}
Message: {message}{newline}
Category: {category}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Thread Name: {threadName}{newline}
Win32 ThreadId:{win32ThreadId}{newline}"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="Information" name="Logging Only">
<listeners>
<add name="Flat File Trace Listener" />
</listeners>
</add>
<add switchValue="Error" name="Errors Only">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="Information" name="Logging Errors & Warnings" />
</specialSources>
</loggingConfiguration>
我需要能够使Logger.IsLoggingEnabled()返回false,我该怎么做?只需使用启用日志记录的筛选器即可。看
if (Logger.IsLoggingEnabled())
{
Logger.Write("Some text...");
}