2012-05-04 5 views
2

저는 EntLib 4.1을 사용하고 있습니다. 로그 항목을 다른 카테고리와 연관시키고 싶습니다. 내 카테고리에는 문맥의 종류 (예 : '일괄'또는 '온라인')와 기능 영역 (예 : '송장'또는 '주문')과 같은 다양한 흥미로운 정보가 반영됩니다.카테고리에 로깅하는 EntLib

로깅 코드를 수행했지만 구성에 문제가 있다고 생각합니다. 내가 달성하기 위해 노력하고있는 모든 항목을 일괄 "범주"일괄 처리 "라는 이벤트 로그 및 모든 다른 응용 프로그램 로그에 기록되도록 기록하는 것입니다. (I 수동으로이 이름으로 사용자 지정 이벤트 로그를 만들었습니다.)

그러나, 대신 응용 프로그램 로그에 기록 얻을 카테고리 배치와 로그 항목 및 각 항목은 다음 프리앰블 포함

 
Message: Tracing to LogSource 'Batch' failed. Processing for other sources will continue. See summary information below for more information. Should this problem persist, stop the service and check the configuration file(s) for possible error(s) in the configuration of the categories and sinks. 

EntLib의 설정을 파일 :

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
     <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> 
    </configSections> 
    <loggingConfiguration name="Logging Application Block" tracingEnabled="true" 
     defaultCategory="APPLICATION" logWarningsWhenNoCategoriesMatch="true"> 
     <listeners> 
      <add source="Project II Logger" formatter="Text Formatter" log="Batch" 
       machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       name="BatchListener" /> 
      <add source="Project II Logger" formatter="Text Formatter" log="Application" 
       machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       traceOutputOptions="Callstack" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       name="DefaultListener" /> 
      <add fileName="c:\temp\trace.log" header="----------------------------------------" 
       footer="----------------------------------------" formatter="ExceptionFormatter" 
       listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       traceOutputOptions="Callstack" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       name="Exception TraceListener" /> 
     </listeners> 
     <formatters> 
      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;ErrorMessages: {errorMessages}" 
       type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       name="ExceptionFormatter" /> 
      <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;ErrorMessages: {errorMessages}" 
       type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
       name="Text Formatter" /> 
     </formatters> 
     <categorySources> 
      <add switchValue="All" name="APPLICATION"> 
       <listeners> 
        <add name="DefaultListener" /> 
       </listeners> 
      </add> 
      <add switchValue="All" name="Batch"> 
       <listeners> 
        <add name="BatchListener" /> 
       </listeners> 
      </add> 
     </categorySources> 
     <specialSources> 
      <allEvents switchValue="All" name="All Events" /> 
      <notProcessed switchValue="All" name="Unprocessed Category" /> 
      <errors switchValue="All" name="Logging Errors &amp; Warnings"> 
       <listeners> 
        <add name="DefaultListener" /> 
       </listeners> 
      </errors> 
     </specialSources> 
    </loggingConfiguration> 
</configuration> 
+0

응용 프로그램 로그에보고 된 메시지는 일괄 범주에 로그인하는 것은 실패했음을 나타냅니다. 스택 추적과 같은 다른 정보를 제공합니까? –

+0

예, 스택 추적이 있습니다. 그러나 내가 로깅하고 있던 맥락이 그 문제와 관련이 있다고 생각할 이유가 없었기 때문에 나는 그것을 게시하지 않았다. –

답변

0

내 생각에 해당 로그에 적절한 이벤트 로그 및/또는 이벤트 소스를 만들지 않았습니다.

구성 파일에 문제가없는 것 같습니다.

bat 파일 또는 콘솔 앱에서 새 로그를 설정하도록 선택한 경우에는 admin 아래에서 실행해야합니다.

creating log and source win 7

+0

당신의 대답은 잘못되었지만 그것을 받아 들일 것입니다. EntLib은 카테고리에 처음 로그인 할 때 로그와 소스를 생성하므로 그렇게 할 필요가 없습니다. 문제는 관련이 있습니다. 동일한 소스를 사용하여 두 곳의 다른 위치에 로그인하려고했습니다. 이것은 Windows 이벤트 로그 모델에서는 불법입니다. 따라서 EntLib에서 비표준 오류 메시지만이 비난 될 수 있습니다. (원본에 소스를 반영하고 소스의 정보를 중앙 집중식 로그에 기록하지만 다른 곳에서는 더 자세한 추적을 기록합니다 허용 안 됨!) –

+0

"Enterprises Library Logging"소스가 자동으로 등록되지만 다른 소스는 자동으로 등록되지 않습니다. 맞춤 소스. – Legends