2010-04-07 2 views
0

간단한 문자열을 로그 파일에 기록하려고합니다. 카테고리, 메시지 및 타임 스탬프 만 필요합니다. 따라서 나는이 같은 app.config에 설정 한 :EnterpriseLibrary를 구성하는 것이 좋습니다. 메시지 및 타임 스탬프 만 출력합니다.

<listeners> 
    <add name="Flat File Destination" 
     fileName="C:\Log\Phoenix.Common.Tests\Debug.log" 
     header="-----------------------------------------------------------------" 
     formatter="Text Formatter" footer="" rollFileExistsBehavior="Increment" rollInterval="Midnight" rollSizeKB="0" timeStampPattern="yyyy-MM-dd" 
     listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
     type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 
</listeners> 
<formatters> 
    <add name="Text Formatter" template="Category: {category} Message: {message} Timestamp: {timestamp}" 
    type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 
</formatters> 

하지만 내 로그 파일에 추가 물건의 모든 종류를 얻을 :

Priority: 50 
EventId: 50 Severity: Verbose 
Title:Testing Log 
Machine: DK-PC-P4740 
App Domain: TestAppDomain: 80803a4f-8e18-47bb-901e-cdac784c8041 
ProcessId: 6492 
Process Name: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\QTAgent32.exe 

가 어떻게이 추가로 물건을 피할 수 있습니까? 누군가가 메시지를 로그 파일에만 기록하는 예제 링크를 보낼 수 있습니까?

답변

0

당신은

단순히 당신은 아마 헤더 & 바닥 글을 제거 할

template="{timestamp(local)}: {message}" 

처럼 뭔가를 당신의 app.config의 섹션에있는 템플릿을 변경 ... 지금이 알아 낸 수 있습니다 섹션의 문자열. 예 : 헤더 = ""