FileLoggingSession 클래스

정의

LoggingChannel 인스턴스에서 기록된 메시지의 대상을 나타냅니다.

public ref class FileLoggingSession sealed : IFileLoggingSession, IClosable
/// [Windows.Foundation.Metadata.Activatable(Windows.Foundation.Diagnostics.IFileLoggingSessionFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class FileLoggingSession final : IFileLoggingSession, IClosable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Foundation.Diagnostics.IFileLoggingSessionFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class FileLoggingSession final : IFileLoggingSession, IClosable
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Foundation.Diagnostics.IFileLoggingSessionFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class FileLoggingSession : System.IDisposable, IFileLoggingSession
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Foundation.Diagnostics.IFileLoggingSessionFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class FileLoggingSession : System.IDisposable, IFileLoggingSession
function FileLoggingSession(name)
Public NotInheritable Class FileLoggingSession
Implements IDisposable, IFileLoggingSession
상속
Object Platform::Object IInspectable FileLoggingSession
특성
구현

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

설명

FileLoggingSession 클래스를 사용하여 앱이 실행됨에 따라 메시지와 데이터를 파일에 지속적으로 기록합니다. WPT(Windows Performance Toolkit) 및 tracerpt.exe 같은 기타 유틸리티를 사용하여 로그 파일을 볼 수 있습니다.

FileLoggingSessionLoggingChannel 인스턴스를 추가하고 FileLoggingSession instance 메서드를 호출하여 채널을 제거하고, 삭제하고, 다른 작업을 수행합니다. 채널 수는 현재 제한되지 않습니다.

참고

Windows Server 2012 R2Windows 8.1 각 앱은 4개의 활성 채널로 제한되며 채널에는 고유한 이름이 있어야 합니다.

FileLoggingSession 클래스는 버퍼가 채워지거나 사용자가 CloseAndSaveToFileAsync를 호출할 때 로그된 메시지를 디스크 파일에 보냅니다. FileLoggingSession 클래스는 순차적 로깅을 사용합니다. 즉, 모든 메시지가 디스크 파일로 전송되고 메시지의 순차적 기록이 유지됩니다. 이는 로그된 메시지를 주문형 디스크로 보내는 LoggingSession 클래스와는 다릅니다. 즉, 앱이 문제를 감지하고 분석을 위해 메모리 내 메시지를 저장하는 경우입니다.

일반적으로 오랜 기간 동안 모든 메시지를 저장해야 하고 앱이 주문형 저장 단계에 부담을 주지 않는 경우 FileLoggingSession 클래스를 사용합니다. LoggingSession 클래스와 마찬가지로 LoggingChannel 인스턴스는 FileLoggingSession instance 추가되고 FileLoggingSession instance 채널을 제거하고 삭제하는 메서드가 있습니다. FileLoggingSession 인스턴스는 로그 파일 롤오버가 발생했을 때 앱에 알리는 새 파일 콜백에 대한 대리자를 사용하여 초기화됩니다. 이 기능은 현재 내부 로그 파일이 용량에 도달하고 연속된 순차 로깅을 위해 새 파일을 만들 때 대리자를 호출합니다. 대리자 콜백은 일시 중단 경계 또는 FileLoggingSession 이 삭제될 때 호출할 수도 있습니다.

LogFileGenerated 이벤트가 호출되면 앱은 현재 닫힌 로그 파일을 나타내는 StorageFile을 받습니다. 앱은 애플리케이션에서 정의한 방식으로 처리하기 위해 로그 파일을 전달할 수 있습니다. 그러면 세션이 새로 만들어지고 현재 열려 있는 현재 로그 파일에 계속 로깅됩니다. 이 로그 파일이 용량에 도달하면 콜백 대리자는 새 파일에 대해 다시 호출되고 프로세스가 반복됩니다.

로깅 이벤트가 완료되면 마지막 로그 파일이 아직 용량에 도달하지 않은 경우 열려 있을 수 있으므로 마지막 로그 파일을 가져오기 위해 CloseAndSaveToFileAsync 를 호출합니다. CloseAndSaveToFileAsync를 사용하여 세션을 닫고 마지막 로그 파일에 액세스할 수도 있습니다. 마지막 로그 파일이 비어 있거나 LogFileGenerated 메서드에서 모든 로그 파일을 이미 보고한 경우 CloseAndSaveToFileAsync 메서드는 null을 반환합니다.

로그 파일은 ApplicationData\Logs 폴더에 만들어집니다.

각 로그 파일의 이름은 세션 이름과 인덱스 이름을 기반으로 합니다. 인덱스는 새 세션을 만들 때마다 다시 설정됩니다. 로그 파일이 최대 크기에 도달할 때마다 닫혀 있고, 인덱스가 증가하며, 새 인덱스를 사용하여 새 로그 파일이 열립니다. 따라서 앱을 다시 시작할 때마다 앱의 이전 instance 생성된 로그 파일을 덮어쓰기 시작합니다.

로그 파일을 닫을 때마다 앱에 알림을 받도록 LogFileGenerated 이벤트에 대한 처리기를 추가할 수 있습니다.

LogFileGenerated 이벤트 또는 CloseAndSaveToFileAsync 메서드를 사용하지 않는 경우 FileLoggingSession은 오래된 로그 파일을 삭제하지 않습니다(새 세션이 이전 세션에서 생성된 파일을 덮어쓸 수 있음). 앱은 필요에 따라 로그 파일을 찾고 정리해야 합니다.

LogFileGenerated 이벤트 또는 CloseAndSaveToFileAsync 메서드를 통해 앱에 로그 파일을 제공하기 전에 특수 로그 파일 이름으로 이름이 바뀝니다. 동일한 로그 파일 이름이 항상 사용되므로 새 로그가 이전 로그를 덮어씁니다. 이러한 방식으로 LogFileGenerated 이벤트 및 CloseAndSaveToFileAsync 메서드를 사용하면 오래된 로그 파일이 ApplicationData 폴더의 공간을 낭비하지 않도록 방지할 수 있습니다.

FileLoggingSession 은 현재 로그 파일을 닫고 현재 로그 파일이 256KB에 도달하면 새 로그 파일을 시작합니다.

생성자

FileLoggingSession(String)

FileLoggingSession 클래스의 새 instance 초기화합니다.

속성

Name

로깅 세션의 이름을 가져옵니다.

메서드

AddLoggingChannel(ILoggingChannel)

현재 로깅 세션에 로깅 채널을 추가합니다.

AddLoggingChannel(ILoggingChannel, LoggingLevel)

현재 로깅 세션에 로깅 채널을 추가합니다. 로깅 채널은 지정된 로깅 수준 이상의 로깅 수준이 있는 이벤트만 허용합니다.

Close()

현재 로깅 세션을 종료합니다.

CloseAndSaveToFileAsync()

현재 로깅 세션을 종료하고 파일에 저장합니다.

Dispose()

관리되지 않는 리소스의 확보, 해제 또는 다시 설정과 관련된 애플리케이션 정의 작업을 수행합니다.

RemoveLoggingChannel(ILoggingChannel)

현재 로깅 세션에서 지정된 로깅 채널을 제거합니다.

이벤트

LogFileGenerated

로그 파일을 저장할 때 발생합니다.

적용 대상

추가 정보