Raw worker logs
Introduction
Raw worker logs provide a simple, lightweight method to output unstructured logs from worker code and inspect the results. Unlike normal deployment logs, these logs are not sent through the SpatialOS logging pipeline and won’t appear in the Inspector’s ‘Logs’ tab. Instead, the logs are simply output to a file where you can inspect them. This means you can structure these logs however you like.
SpatialOS generates a raw worker log file for each worker instance when it starts a deployment. Worker instances can then write logs to this file for the duration of the deployment. However, for cloud deployments, the files are deleted when the deployment stops.
When debugging issues with worker instances, raw worker logs can be a useful tool for extracting debug information from the system. However, they lack much of the functionality of the normal SpatialOS logging infrastructure, so you should only use them in particular debugging scenarios. For example:
- When server-worker instances are having connection issues, you can obtain debug logs from raw worker logs.
- When you want to extract a large amount of unstructured debug information from a worker instance, such as heap dumps, raw worker logs provide a convenient method for this.
Enabling raw worker logs
In order for the raw worker log file to be available to the worker instance,
you need to add the ${IMPROBABLE_LOG_FILE}
argument to the managed
field of the worker configuration file.
SpatialOS substitutes this argument with the location of the worker’s raw log file.
You can then append logs to this file.
For more information, see Managed worker launch configuration.
Writing raw worker logs
Append to the ${IMPROBABLE_LOG_FILE}
file as passed via your managed worker’s launch configuration.
You can create new files next to the ${IMPROBABLE_LOG_FILE}
file for rotating logs.
Reading raw worker logs
Local deployments
The log files are located in the workspace at logs/<date>_<time>/workers/<worker>/<worker_id>.log
.
Cloud deployments
There are two ways to access raw worker logs for cloud deployments:
From the Inspector
In the Inspector sidebar, select a worker instance and then click Raw Worker Logs.
From the deployment page in the Console
Select the Advanced tab followed by the worker_nanny node, and then click Raw logs.
Both of these methods take you to a simple web interface for inspecting the raw worker logs for the deployment.
You can then find the raw logs for a particular worker instance at <worker>/<worker_id>.log
.