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 functioncreateManifest
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
Open the AUTOSAR adaptive model.
使用AUTOSAR AUTOSAR属性函数来设置property
LogMode
to Console:apiObj = autosar.api.getAUTOSARProperties(modelName); processPath = find(apiObj,'/','Process','PathType','FullyQualified'); set(apiObj,processPath{1},'LogTraceLogMode','Console');
Optionally, set the logging verbosity level to Verbose.
set(apiObj,processPath{1},'LogTraceDefaultLogLevel','Verbose');
Generate code and ARXML files for the model. The build generates the logging properties into the file
modelname_ExecutionManifest.arxml
.If you intend to build and run a Linux standalone executable for the adaptive model, use the
createManifest
function to generate the manifest fileExecutionManifest.json
在当前的工作文件夹中。createManifest(apiObj);
Before you run the Linux executable, verify that the JSON execution manifest file and executable file are in the same folder.
Execute the application and see the log messages appear on the console.
Logging to File
Open the AUTOSAR adaptive model.
使用AUTOSAR AUTOSAR属性函数来设置property
LogMode
to File:apiObj = autosar.api.getAUTOSARProperties(modelName); processPath = find(apiObj,'/','Process','PathType','FullyQualified'); set(apiObj,processPath{1},'LogTraceLogMode','File');
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');
Optionally, set the logging verbosity level to Verbose.
set(apiObj,processPath{1},'LogTraceDefaultLogLevel','Verbose');
Generate code and ARXML files for the model. The build generates the logging properties into the file
modelname_ExecutionManifest.arxml
.If you intend to build and run a Linux standalone executable for the adaptive model, use the
createManifest
function to generate the manifest fileExecutionManifest.json
在当前的工作文件夹中。createManifest(apiObj);
Before you run the Linux executable, verify that the JSON execution manifest file and executable file are in the same folder.
Execute the application and verify that the log file is created at the specified or default location.
Logging to Network
Open the AUTOSAR adaptive model.
使用AUTOSAR AUTOSAR属性函数来设置property
LogMode
to Network:apiObj = autosar.api.getAUTOSARProperties(modelName); processPath = find(apiObj,'/','Process','PathType','FullyQualified'); set(apiObj,processPath{1},'LogTraceLogMode','Network');
Optionally, set the logging verbosity level to Verbose.
set(apiObj,processPath{1},'LogTraceDefaultLogLevel','Verbose');
Generate code and ARXML files for the model. The build generates the logging properties into the file
modelname_ExecutionManifest.arxml
.Before you run the Linux executable, verify that the JSON execution manifest file and executable file are in the same folder.
Initialize the AUTOSAR run-time environment for adaptive applications with following command.
autosar.ara.initialize
Execute the application and see the log messages appear on the network.