samples/cpp/windows/console/samples/diagnostics_logging_samples.cpp
void DiagnosticsLoggingEventLoggerWithFilter()
{
    std::mutex mtx;
    std::vector<std::string> messages;

    // Register a callback that will get invoked by Speech SDK on every new log message
    EventLogger::SetCallback([&messages, &mtx](std::string message) {
            // Copy the string and store it for further processing. Do not do any processing in the event thread!
            std::unique_lock<std::mutex> lock(mtx);
            messages.push_back(message);
        });

    // Set an event filter, such that the callback will be invoked only for traces
    // that contain either one of the filter strings provided.
    std::initializer_list<std::string> filters = { "YourFirstString", "YourSecondString" };
    EventLogger::SetFilters(filters);

    // Do your Speech SDK calls... for example:
    auto config = SpeechConfig::FromSubscription("YourSubscriptionKey", "YourServiceRegion");
    auto recognizer = SpeechRecognizer::FromConfig(config);

    // Stop logging and clear filters by setting an empty callback
    EventLogger::SetCallback();

    // Clear filters
    EventLogger::SetFilters();

    // See resulting logs on the console
    std::cout << "Here are the logs we captured:\n";
    for (std::string message : messages)
    {
        std::cout << message;
    }
}
// Shows how to enabled Speech SDK trace logging events. Microsoft may ask you to collect logs
// in order to investigate an issue you reported
Shows how to enabled Speech SDK trace logging events. Microsoft may ask you to collect logs
in order to investigate an issue you reported
Shows how to enabled Speech SDK trace logging events . Microsoft may ask you to collect logs in order to investigate an issue you reported
void DiagnosticsLoggingEventLoggerWithFilter()
{
    std::mutex mtx;
    std::vector<std::string> messages;
    EventLogger::SetCallback([&messages, &mtx](std::string message) {
            std::unique_lock<std::mutex> lock(mtx);
            messages.push_back(message);
        });
    std::initializer_list<std::string> filters = { "YourFirstString", "YourSecondString" };
    EventLogger::SetFilters(filters);
    auto config = SpeechConfig::FromSubscription("YourSubscriptionKey", "YourServiceRegion");
    auto recognizer = SpeechRecognizer::FromConfig(config);
    EventLogger::SetCallback();
    EventLogger::SetFilters();
    std::cout << "Here are the logs we captured:\n";
    for (std::string message : messages)
    {
        std::cout << message;
    }
}
void DiagnosticsLoggingEventLoggerWithFilter ( ) { std :: mutex mtx ; std :: vector < std :: string > messages ; EventLogger :: SetCallback ( [ & messages , & mtx ] ( std :: string message ) { std :: unique_lock < std :: mutex > lock ( mtx ) ; messages . push_back ( message ) ; } ) ; std :: initializer_list < std :: string > filters = { " " , " " } ; EventLogger :: SetFilters ( filters ) ; auto config = SpeechConfig :: FromSubscription ( " " , " " ) ; auto recognizer = SpeechRecognizer :: FromConfig ( config ) ; EventLogger :: SetCallback ( ) ; EventLogger :: SetFilters ( ) ; std :: cout << " \n " ; for ( std :: string message : messages ) { std :: cout << message ; } }
Shows how to enabled Speech SDK trace logging events.
Shows how to enabled Speech SDK trace logging events .
// Register a callback that will get invoked by Speech SDK on every new log message // Copy the string and store it for further processing. Do not do any processing in the event thread! // Set an event filter, such that the callback will be invoked only for traces // that contain either one of the filter strings provided. // Do your Speech SDK calls... for example: // Stop logging and clear filters by setting an empty callback // Clear filters // See resulting logs on the console