Main Content

Configure Run-Time Logging for AUTOSAR Adaptive Executables

As defined in the AUTOSAR Specification of Diagnostic Log and Trace, adaptive applications can forward event logging information to a console, a file, or network. This allows you to collate and analyze log data from multiple applications. By default, the application logs event messages to the local console. To view the log data from a file or network, you can use third-party tools.

To modify the default run-time logging behavior for an adaptive model, use AUTOSAR property functions, including set. Code generation exports the specified logging properties to an ARXML execution manifest file. The manifest file is used to configure aspects of the run-time behavior of the adaptive application Linux® executable, such as the logging mode and verbosity level.

If you build a Linux executable from the adaptive model, you can use the AUTOSAR property function createManifest to generate a JSON execution manifest file. The JSON file modifies the default logging behavior for the executable. You can generate the JSON execution manifest file after you build the Linux executable. Before you run the Linux executable, verify that the JSON execution manifest file and executable file are in the same folder.

Logging to Console

  1. Open the AUTOSAR adaptive model.

  2. Use AUTOSAR property functions to set the AUTOSAR property LogMode to Console:

    apiObj = autosar.api.getAUTOSARProperties(modelName);
    dltLogSinkPath = apiObj.find('/','DltLogSink','PathType','FullyQualified');
    apiObj.set(dltLogSinkPath{1}, 'LogTraceLogMode', 'Console');

  3. Optionally, set the logging verbosity level to Verbose.

    apiObj.set(dltLogSinkPath{1}, 'DefaultLogThreshold', 'Verbose');

  4. Generate code and ARXML files for the model. The build generates the logging properties into the file MachineManifest.arxml.

  5. If you intend to build and run a Linux standalone executable for the adaptive model, use the createManifest function to generate the manifest file ExecutionManifest.json in the current working folder.

    createManifest(apiObj);

  6. Before you run the Linux executable, verify that the JSON execution manifest file and executable file are in the same folder.

  7. Execute the application and see the log messages appear on the console.

Logging to File

  1. Open the AUTOSAR adaptive model.

  2. Use AUTOSAR property functions to set the AUTOSAR property LogMode to File:

    apiObj = autosar.api.getAUTOSARProperties(modelName);
    dltLogSinkPath = apiObj.find('/','DltLogSink','PathType','FullyQualified');
    apiObj.set(dltLogSinkPath{1}, 'LogTraceLogMode', 'File');

  3. Optionally, specify the path to the log file. By default the log file will be saved in the executable folder.

    apiObj.set(dltLogSinkPath{1},'LogTraceFilePath',<customFilePath>);

  4. Optionally, set the logging verbosity level to Verbose.

    apiObj.set(dltLogSinkPath{1},'DefaultLogThreshold','Verbose');

  5. Generate code and ARXML files for the model. The build generates the logging properties into the file MachineManifest.arxml.

  6. If you intend to build and run a Linux standalone executable for the adaptive model, use the createManifest function to generate the manifest file ExecutionManifest.json in the current working folder.

    createManifest(apiObj);

  7. Before you run the Linux executable, verify that the JSON execution manifest file and executable file are in the same folder.

  8. Execute the application and verify that the log file is created at the specified or default location.

Logging to Network

  1. Open the AUTOSAR adaptive model.

  2. Use AUTOSAR property functions to set the AUTOSAR property LogMode to Network:

    apiObj = autosar.api.getAUTOSARProperties(modelName);
    dltLogSinkPath = apiObj.find('/','DltLogSink','PathType','FullyQualified');
    apiObj.set(dltLogSinkPath{1},'LogTraceLogMode','Network');

  3. Optionally, set the logging verbosity level to Verbose.

    apiObj.set(dltLogSinkPath{1},'DefaultLogThreshold','Verbose');

  4. Generate code and ARXML files for the model. The build generates the logging properties into the file MachineManifest.arxml.

  5. Initialize the AUTOSAR run-time environment for adaptive applications using the Linux Runtime Manager (Embedded Coder). For more information, see Build Simulink Model and Deploy Application (Embedded Coder).

  6. Start the application using Linux Runtime Manager and see the log messages appear on log viewer.

Note

To use the ara::log block in models, copy it from the adaptive_msg_sender model from the Get Started with Embedded Coder Support Package for Linux Applications example.

Open the example model containing ara::log block by using the command:

openExample("adaptive_msg_sender");

See Also

Related Topics