# How to configure, start and stop logging

This sample application demonstrates how to configure, start and stop diagnostics logging.

1. Create the initialization callback object to be notified when initialization is complete and the object is ready to be used.

auto initCb = [&](telux::common::ServiceStatus status) {
       initPromise.set_value(status);
    };
    Copy to clipboard

2. Get the DiagnosticsFactory and DiagLogManager instances.

auto &diagFactory = telux::platform::diag::DiagnosticsFactory::getInstance();
    diagMgr  = diagFactory.getDiagLogManager(initCb);
    Copy to clipboard

3. Ensure subsystem is ready.

subSystemStatus = initPromise.get_future().get();
    Copy to clipboard

4. Ensure logging is not currently in progress.

if(diagStatus.isLoggingInProgress) {
       std::cout << " *** Logging already in progress - quitting application *** " << std::endl;
       break;
    }
    Copy to clipboard

5. Configure diagnostics logging.

telux::platform::diag::DiagConfig fileMethodCfg {};
    fileMethodCfg.method = telux::platform::diag::LogMethod::FILE;
    fileMethodCfg.srcType = telux::platform::diag::SourceType::DEVICE;
    fileMethodCfg.srcInfo.device = static_cast<uint8_t>(2);
    fileMethodCfg.mdmLogMaskFile = maskFile;
    fileMethodCfg.modeType = telux::platform::diag::DiagLogMode::STREAMING;
    fileMethodCfg.methodConfig.fileConfig.maxSize = 0;
    fileMethodCfg.methodConfig.fileConfig.maxNumber = 0;
    errCode = diagMgr->setConfig(fileMethodCfg);
    Copy to clipboard

6. Start logging.

errCode = diagMgr->startLogCollection();
    if(telux::common::ErrorCode::SUCCESS != errCode) {
       std::cout << "Failed to start logging... Error Code: "
                 << static_cast<int>(errCode) << ". quitting application" <<std::endl;
       break;
    }
    Copy to clipboard

7. Wait for 10 seconds.

std::this_thread::sleep_for(std::chrono::milliseconds(10000));
    Copy to clipboard

8. Stop logging.

errCode = diagMgr->stopLogCollection();
    if(telux::common::ErrorCode::SUCCESS != errCode) {
       std::cout << "Failed to stop logging... Error Code: "
                 << static_cast<int>(errCode) << ". quitting application" <<std::endl;
       break;
    }
    Copy to clipboard

9. Cleanup.

if(diagMgr) {
       diagMgr = nullptr;
    }
    Copy to clipboard

Last Published: May 20, 2026

[Previous Topic
Diagnostics](https://docs.qualcomm.com/bundle/publicresource/80-PF458-7/topics/diag.md) [Next Topic
TelSDK logging](https://docs.qualcomm.com/bundle/publicresource/80-PF458-7/topics/telsdk-logging.md)