Enterprise Library Logger를 사용하여 여러 파일을 날짜별로 그룹화 할 수 있습니까? 예를 들어 Trace-08-22-2011.log, Trace-08-23-2011.log를 예로들 수 있습니다.여러 파일에 쓰기 Enterprise Library Logger
1
A
답변
1
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<!--Flat File Trace Listener-->
<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="Default Category" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add source="Enterprise Library Logging" formatter="Text Formatter"
log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Formatted EventLog TraceListener" />
<add fileName="D:\Works\GPIH\GPIAgent\Web\Log\Logger.log"
formatter="One Line Formatter" rollFileExistsBehavior="Increment"
rollInterval="Midnight" rollSizeKB="10000" timeStampPattern="yyyy-MM-dd"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Rolling Flat File" />
</listeners>
<formatters>
<add template="Timestamp: {timestamp}{newline}
Message: {message}{newline}
Category: {category}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Text Formatter" />
<add template="{timestamp(local)} Cat: {category} Pri: {priority} EId: {eventid} Sev: {severity} {message} Title:{title} Machine: {machine} Application Domain: {appDomain} Process Id: {processId} Process Name: {processName} Win32 Thread Id: {win32ThreadId} Thread Name: {threadName} Extended Properties: {dictionary({key} - {value}
)}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="One Line Formatter" />
</formatters>
<logFilters>
<add name="LogEnabled Filter"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.LogEnabledFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
enabled="true" />
</logFilters>
<categorySources>
<add switchValue="Warning" name="Default Category">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events">
<listeners>
<add name="Rolling Flat File" />
</listeners>
</allEvents>
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
1
예 (Enterprise-Library와 함께 제공되는 TraceListeners에는 포함되지만 포함되지 않음). 필요한 것은 커스텀 TraceListener이거나 적어도 트레이스 리스너 팩토리 (GetCreationExpression)로서 간접적으로 사용되는 TraceListenerData입니다.
당신이 기술 한 가장 쉬운 방법은 RollingFlatFileTraceListenerData에서 상속 받고 GetCreationExpression을 오버라이드하는 것입니다. 그것은 당신이 원하는대로 설정할 수있는 this.FileName 보호 필드가 있습니다. 예를 들어, 당신은 사용자 정의 토큰 (타임 스탬프)
/// <summary>
/// Returns a lambda expression that represents the creation of the trace listener described by this
/// configuration object.
/// </summary>
/// <returns>A lambda expression to create a trace listener.</returns>
protected override Expression<Func<TraceListener>> GetCreationExpression()
{
// Resolve tokens in FileName
string fileName = ResolveTokens(this.FileName);
return
() =>
new RollingFlatFileTraceListener(
fileName,
this.Header,
this.Footer,
Container.ResolvedIfNotNull<ILogFormatter>(this.Formatter),
this.RollSizeKB,
this.TimeStampPattern,
this.RollFileExistsBehavior,
this.RollInterval,
this.MaxArchivedFiles);
}
그리고 구성 해결할 수 :
<add name="All Activities Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Sample.CustomFlatFileTraceListenerData, Sample"
fileName="%TEMP%\{timestamp}.log"
footer="" formatter="Detail Text Formatter" rollFileExistsBehavior="Overwrite"
rollInterval="Day" timeStampPattern="yyyy-MM-dd" maxArchivedFiles="10" />
관련 문제
- 1. Enterprise Library Logger - 전자 메일 서버 설정
- 2. Enterprise Library 5.0은 Enterprise Library 4.1과 호환됩니까?
- 3. Microsoft Enterprise Library 유용한가요?
- 4. Enterprise Library 1.0은 SQL Server 2005를 지원합니까?
- 5. Enterprise Library 4.0을 어떻게 배울 수 있습니까?
- 6. LINQ to SQL vs. Enterprise Library
- 7. .net Mef with Enterprise Library 5.0
- 8. Windows 7에서 Enterprise Library 4.1이 지원됩니까?
- 9. Microsoft Enterprise Library 2.0에서 5.1로 업그레이드
- 10. Enterprise Library 모든 규칙 집합의 유효성 확인
- 11. 파일에 여러 번 쓰기 IOException 가져 오기
- 12. 루비의 여러 스레드에서 단일 파일에 쓰기
- 13. 파일에 쓰기
- 14. ASP.NET의 로그 파일에 쓰기
- 15. 파일에 다중 NSData 쓰기
- 16. 파일에 동시에 쓰기
- 17. 프로그래밍 방식으로 Enterprise Library 로깅 수신기 설정을 변경할 수 있습니까?
- 18. Enterprise Library 4.0 ValidationProvider 자체 유효성 검사 질문
- 19. Enterprise Library Email Trace Listener가 우리 메일 서버를 죽이고 있습니다.
- 20. Enterprise Library Logging을 사용하여 사용자의 ApplicationData 폴더에 로그온하는 방법은 무엇입니까?
- 21. File logger in C#
- 22. 번들에있는 파일에 쓰기?
- 23. 자바의 파일에 문자열 쓰기
- 24. 파일에 NSImage 쓰기
- 25. fopen 파일에 EOF 쓰기
- 26. 원격 서버의 파일에 쓰기
- 27. 이진 문자열을 파일에 쓰기
- 28. PHP 파일에 쓰기
- 29. C++ : 파일에 쓰기
- 30. 파이썬이 파일에 쓰기
감사합니다,하지만 그는하지 않았다; P는 :( –