2012-06-11 3 views
0

로깅을 위해 엔터프라이즈 라이브러리 5.0을 사용하고 있으며 로깅을 끄는 방법을 모르겠습니다. 현재 스위치가 켜져 있고 작동해야합니다.EL 5.0 로깅 켜기/끄기

로깅에 대한 내 web.config 섹션은 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> 

위의 몇 줄에 ... 내 데이터를 바꿨습니다.

내가 Logger.IsLoggingEnabled()가 false를 반환 할 수 있어야합니다
if (Logger.IsLoggingEnabled()) 
{ 
    Logger.Write("Some text..."); 
} 

, 내가 그걸 어떻게해야합니까 : 나는 파일에 기록하려면이 옵션을 사용하고 순간

?

답변

관련 문제