FileLoggingSession class

Applies to Windows and Windows Phone

Represents the destination of logged messages from LoggingChannel instances.

Syntax


var fileLoggingSession = new Windows.Foundation.Diagnostics.FileLoggingSession();

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06030000)]

Members

The FileLoggingSession class has these types of members:

Constructors

The FileLoggingSession class has these constructors.

ConstructorDescription
FileLoggingSession Initializes a new instance of the FileLoggingSession class.

 

Events

The FileLoggingSession class has these events.

EventDescription
LogFileGenerated Raised when a log file is saved.

 

Methods

The FileLoggingSession class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
AddLoggingChannel(ILoggingChannel) Adds a logging channel to the current logging session.
AddLoggingChannel(ILoggingChannel, LoggingLevel) Adds a logging channel with the specified logging level to the current logging session.
Close [C++, JavaScript]Ends the current logging session.
CloseAndSaveToFileAsync Ends the current logging session and saves it to a file.
Dispose [C#, VB]Performs tasks associated with freeing, releasing, or resetting unmanaged resources.
RemoveLoggingChannel Removes the specified logging channel from the current logging session.

 

Properties

The FileLoggingSession class has these properties.

PropertyAccess typeDescription

Name

Read-onlyGets the name of the logging session.

 

Remarks

Use the FileLoggingSession class to log messages and data to a file continuously as your app runs. You can view the log files by using the Windows Performance Toolkit (WPT) and other utilities like tracerpt.exe.

Add LoggingChannel instances to a FileLoggingSession, and call FileLoggingSession instance methods to remove channels, dispose, and perform other operations.

FileLoggingSession instances keep logged messages in memory until the CloseAndSaveToFileAsync method is called. This enables on-demand saving of events until the app saves the in-memory messages.

The FileLoggingSession class sends logged messages to disk files as they are logged. The FileLoggingSession class uses sequential logging, which means that all messages are sent to a disk file, and a sequential history of messages is retained. This is distinct from the LoggingSession class, which sends logged messages to disk on-demand, and this happens when there's a problem and the immediate history of in-memory messages is needed for analysis.

Use the FileLoggingSession class when you know that all messages need to be saved, usually over a long period of time, and when the app can't be burdened with on-demand saving steps. Like theLoggingSession class, LoggingChannel instances are added to a FileLoggingSession instance, and the FileLoggingSession instance has methods to remove channels and dispose. FileLoggingSession instances are initialized with a delegate to a new file callback, which notifies the app when a log file rollover has occurred. The feature invokes the delegate when the current internal log file has reached capacity and a new file is being created for continued sequential logging. The delegate callback can also be called at suspend boundaries, or when the FileLoggingSession is disposed.

When the delegate is invoked, the app receives an StorageFile that represents the now-closed log file. The app can forward the log file for processing in an application-defined way. After this, the session continues logging to a newly created and now-open current log file. When this log file reaches capacity, the callback delegate is invoked again for the new file, and the process repeats.

Requirements

Minimum supported client

Windows 8.1 [Windows Store apps only]

Minimum supported server

Windows Server 2012 R2 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.Foundation.Diagnostics
Windows::Foundation::Diagnostics [C++]

Metadata

Windows.winmd

See also

LoggingChannel
Object
IFileLoggingSession
IClosable

 

 

Show:
© 2014 Microsoft