2009-03-26 2 views
1

log4net에서 entlib 로거로 이동해야했습니다. 네가 뭘 생각하는지 알아? :)Entlib 로거에 대한 템플릿 설정

어쨌든, 쓸데없는 정보를 없애기 위해 로거에 대한 기본 템플릿을 변경하려고합니다. 예를 들어 우선 순위와 같은 것입니다.하지만 로그에는 여전히 값이 있습니다. -types)를 작성하십시오. 템플릿은 다음과 같습니다.


<add template="Timestamp: {timestamp}{tab}Category: {category}{tab}Severity: {severity}{newline}
Process Id: {processId}{tab}Thread Id: {win32ThreadId}{newline}
Message: {message}" 
     type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
     name="Text Formatter" /> 

아직 이벤트 ID, 제목, 기계, 우선 순위 및 프로세스 이름이 표시됩니다. 어떤 도움을 주시면 감사하겠습니다.


번호를 사용하여 기존의 롤 오버 로그 파일 이름 대신에 타임 스탬프 및 최대 롤 오버 카운트 지정하는 방법이 있나요 - log4net처럼은?

답변

1

구성 파일 (app.config)에는 요소 포맷터가 있습니다. 이를 변경할 수 있습니다 (config 도구 사용). 내 작품 중 하나는 다음과 같습니다.

<add 
template="{timestamp} {machine}:{processId}:{threadName}({win32ThreadId}) {message}" 
    type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
    name="LogFileFormatter" /> 
관련 문제