I am using enterprise library 5.0 for logging and I am not sure how to switch off the logging. Currently it is switched on and workng as it should.
Here is my web.config section on logging, it was created with automatically with the EL 5.0 GUI.
<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>
I have replaced my data with ... in some lines above.
At the moment I'm using this to log to a file:
if (Logger.IsLoggingEnabled())
{
Logger.Write("Some text...");
}
I need to be able to make Logger.IsLoggingEnabled() return false, how do I do that?