class Diagnostics::Logging::FileLogger

Class with static methods to control file-based SDK logging. Turning on logging while running your Speech SDK scenario provides detailed information from the SDK's core native components. If you report an issue to Microsoft, you may be asked to provide logs to help Microsoft diagnose the issue. Your application should not take dependency on particular log strings, as they may change from one SDK release to another without notice. FileLogger is the simplest logging solution and suitable for diagnosing most on-device issues when running Speech SDK. Added in version 1.20.0.

File logging is a process wide construct. That means that if (for example) you have multiple speech recognizer objects running in parallel, there will be one log file containing interleaved logs lines from all recognizers. You cannot get a separate log file for each recognizer.

Members

Start

Syntax: public inline static void Start ( const std::string & filePath , bool append );

Starts logging to a file.

Parameters

  • filePath Path to a log file on local disk

  • append Optional. If true, appends to existing log file. If false, creates a new log file

Note that each write operation to the file is immediately followed by a flush to disk. For typical usage (e.g. one Speech Recognizer and a Solid State Drive (SSD)) this should not cause performace issues. You may however want to avoid file logging when running many Speech SDK recognizers or other SDK objects simultaneously. Use MemoryLogger or EventLogger instead.

Stop

Syntax: public inline static void Stop ( );

Stops logging to a file.

This call is optional. If logging as been started, the log file will be written when the process exists normally.

SetFilters

Syntax: public inline static void SetFilters ( std::initializer_list< std::string > filters );

Sets or clears the filters that apply to file logging. Once filters are set, the callback will be invoked only if the log string contains at least one of the strings specified by the filters. The match is case sensitive.

Parameters

  • filters Optional. Filters to use, or an empty list to remove previously set filters.

SetLevel

Syntax: public inline static void SetLevel ( Level level );

Sets the level of the messages to be captured by the logger.

Parameters

  • level Maximum level of detail to be captured by the logger.