×

Log Files

The PLC Shift run time generates detailed log files as it executes. These log files are very useful when understanding what's happening with the system. All timestamps in all log files are in UTC.
 

Types of Logs

here are two main types of log files: Device level logs and application level logs. Device level logs are generated at the device level and are not specific to any application. Device log files include:
 
  • Application Log. This is a log generated by the core or base PLC Shift runtime. This file will have information about creating, deleting and reconfiguring applications, starting and stopping background tasks, export to the cloud, and so on.
  • Controller Driver Log. This log is generated by the driver that communicates with the PLC. This log will only have entries if the controller driver is enabled and active.
  • MQTT Log. This log is generated by the MQTT task. This log will only have entries if MQTT is enabled and active.
  • IO Task Log. This log is generated by the IO task and contains entries when IO is polled directly from an application.
 
 Each active application generates the following logs:
 
  • Diagnostic Log. This log contains details about the execution of the app.
  • Configuration Change Log. This log contains information about parameter changes. Every configuration and control parameter change is logged here.
 

Log Files

Logs are stored in the CLEF format, which is essentially JSON but with single character field definitions. Logs can be analyzed and queried using a CLEF viewing tool, or viewed in a text editor.
 
For each type of log, a new log file is created every day at midnight local time. Old log files are cleaned up automatically when they are older than 14 days. On the remote device, logs are stored in disk in the '/var/plc-shift-app/logs' directory. App logs are stored in a directory that is named for the application's GUID and device level logs are stored in named directories.
 
Log Files Locations On Remote Device
 
Application Log Files on Disk
 

Retreive and View Logs

Device Logs

When connected and online, device level logs can be retrieved using log specific tabs on the 'Synchronize' tab. After logs files are retrieved, they can be viewed when offline or online.
 
Device Level Log Tabs
 
View Controller Driver Log

Application Logs

When connected and online, application logs can be retrieved by selecting the app specific tab at the bottom of the screen and and then selecting the log specific tab. Make sure the app is checked in the tree view so that the app specific tab exists.
 
After logs files are retrieved, they can be viewed when offline or online.
 
Application Specific Configuration Change Log
 

View Live Logs

On remotes devices that use the Systemd initialization system, logs can be viewed as the system is executing. Log entries from all logs except application configuration change logs are shown in a single view, which sometimes makes is easier to understand the sequence of events that occurred.
 
To view live logs, run the following command in the terminal: 'sudo journalctl -f -u plc-shift-app.service' This command requires super user privileges.
 
Opto22 PR1 and PR2 devices that use the SysV init system and do not support this method. This includes devices at firmware version 3.4 and older.
 
'
Live Log View
 

Logging Level

The amount of detail in log files can be changed via control parameters. Choose 'Verbose' for the most detailed logging and 'Errors' for the least detailed logging. The default value is 'Info'. Note that choosing very detailed logging may impact system performance and should only be done when necessary.
 
For device level logs, use the 'Logging Level' parameter in the 'Control' group at the device level.
 
For application level logs, use the 'Logging Level' parameter in the 'App Control' group at the application. This value can be synchronized with the PLC or published and subscribed via MQTT, so it's possible to change it at runtime without using PLC Shift Manager.
 
App Logging Level

Compact Log Viewer

'Compact Log Viewer' is a 3rd party program allows you to view and query CLEF files. This program is open source and the source code is available on GitHub. There is also a compiled version available in the Windows Store.
 
This program only allows you to open a single log file at a time, but it will order the log entries by timestamp, so entries in any log file do not need be in any specific order. This means that you can concatenate multiple log files into a single file to have a unified view of what's happening with the system. For example, you could combine an app's diagnostic and the MQTT log to a sequence of events for both of these tasks.
 
To easily concatenate multiple files into a single file, use this command at the Windows command line: copy /b *.log newfile.txt . All the log files in the directory will be copied to a new file that is called 'newfile.txt'. This one file can be opened in the Compact Log Viewer program.
 
Compact Log Viewer