Main Content

Configure Run-Time Logging for AUTOSAR Adaptive Executables

As defined in the AUTOSARSpecification 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, includingset. 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 functioncreateManifestto 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. 使用AUTOSAR AUTOSAR属性函数来设置propertyLogModeto 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 filemodelname_ExecutionManifest.arxml.

  5. If you intend to build and run a Linux standalone executable for the adaptive model, use thecreateManifestfunction to generate the manifest fileExecutionManifest.json在当前的工作文件夹中。

    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. 使用AUTOSAR AUTOSAR属性函数来设置propertyLogModeto 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 filemodelname_ExecutionManifest.arxml.

  6. If you intend to build and run a Linux standalone executable for the adaptive model, use thecreateManifestfunction to generate the manifest fileExecutionManifest.json在当前的工作文件夹中。

    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. 使用AUTOSAR AUTOSAR属性函数来设置propertyLogModeto 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 filemodelname_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