EL 5.0 toggling logging on/off

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}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;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 &amp; 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?

Answers


Just use the Logging Enabled filter for this. See http://msdn.microsoft.com/en-us/library/ff664548%28v=PandP.50%29.aspx.


Need Your Help

Seeking an algorithm to efficiently layout calendar event banners

algorithm calendar minimize

I'm looking for an algorithm to efficiently place all-day/multi-day event banners, much like the month view in Outlook or Google Calendar. I have a number of events with a begin and end date, order...

Attaching event on the fly with prototype

ajax events prototypejs

I've been scratching my head over this for an hour... I have a list of todo which has done button on each item. Every time a user clicks on that, it's supposed to do an Ajax call to the server, cal...