저는 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}
Message: {message}
Category: {category}
Priority: {priority}
EventId: {eventid}
Severity: {severity}
Title:{title}
Machine: {machine}
Application Domain: {appDomain}
Process Id: {processId}
Process Name: {processName}
Win32 Thread Id: {win32ThreadId}
Thread Name: {threadName}
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}
Message: {message}
Category: {category}
Priority: {priority}
EventId: {eventid}
Severity: {severity}
Title:{title}
Machine: {machine}
Application Domain: {appDomain}
Process Id: {processId}
Process Name: {processName}
Win32 Thread Id: {win32ThreadId}
Thread Name: {threadName}
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 & Warnings">
<listeners>
<add name="DefaultListener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
</configuration>
응용 프로그램 로그에보고 된 메시지는 일괄 범주에 로그인하는 것은 실패했음을 나타냅니다. 스택 추적과 같은 다른 정보를 제공합니까? –
예, 스택 추적이 있습니다. 그러나 내가 로깅하고 있던 맥락이 그 문제와 관련이 있다고 생각할 이유가 없었기 때문에 나는 그것을 게시하지 않았다. –