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);
    processPath = find(apiObj,'/','Process','PathType','FullyQualified');
    set(apiObj,processPath{1},'LogTraceLogMode','Console');

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

    set(apiObj,processPath{1},'LogTraceDefaultLogLevel','Verbose');

  4. Generate code and ARXML files for the model. The build generates the logging properties into the file modelname_ExecutionManifest.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);
    processPath = find(apiObj,'/','Process','PathType','FullyQualified');
    set(apiObj,processPath{1},'LogTraceLogMode','File');

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

    set(apiObj,processPath{1},'LogTraceFilePath','customFilePath');

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

    set(apiObj,processPath{1},'LogTraceDefaultLogLevel','Verbose');

  5. Generate code and ARXML files for the model. The build generates the logging properties into the file modelname_ExecutionManifest.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);
    processPath = find(apiObj,'/','Process','PathType','FullyQualified');
    set(apiObj,processPath{1},'LogTraceLogMode','Network');

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

    set(apiObj,processPath{1},'LogTraceDefaultLogLevel','Verbose');

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

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

  6. Initialize the AUTOSAR run-time environment for adaptive applications with following command.

    autosar.ara.initialize

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

See Also