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
Open the AUTOSAR adaptive model.
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');
Optionally, set the logging verbosity level to Verbose.
apiObj.set(dltLogSinkPath{1}, 'DefaultLogThreshold', 'Verbose');
Generate code and ARXML files for the model. The build generates the logging properties into the file
MachineManifest.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
in the current working folder.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.
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');
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>);
Optionally, set the logging verbosity level to Verbose.
apiObj.set(dltLogSinkPath{1},'DefaultLogThreshold','Verbose');
Generate code and ARXML files for the model. The build generates the logging properties into the file
MachineManifest.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
in the current working folder.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.
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');
Optionally, set the logging verbosity level to Verbose.
apiObj.set(dltLogSinkPath{1},'DefaultLogThreshold','Verbose');
Generate code and ARXML files for the model. The build generates the logging properties into the file
MachineManifest.arxml
.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).
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
- Support Package Installation (Embedded Coder)
- Analyze Logged Messages (Embedded Coder)
- Get Started with Embedded Coder Support Package for Linux Applications
- Event Communication Between AUTOSAR Adaptive Applications Using Message Polling
- Event Communication Between AUTOSAR Adaptive Applications Using Message Triggering