Enable logging for functions
StackState Self-hosted v4.6.x
This page describes StackState version 4.6.
Overview
For debugging purposes, it may be helpful to enable logging for a StackState function. You can add logging statements to functions and then use the StackState CLI to set the logging level for individual instances of a check function, event handler function, propagation function or view state configuration function. Log messages will be added to the StackState log file stackstate.log
. It is not currently possible to enable logging for other function types.
Set the logging level for a function instance
To enable logging for an instance of a function, use its ID to set a logging level in the StackState CLI. Note that the function itself will have an ID and each instance of the function relating to a component or view in StackState will have a separate ID.
The logging level should be set using the ID for an instance of a function, not the ID of the function itself.
Find the ID for the instance of the function that you want to enable logging for:
Use the StackState CLI to set the logging level for the ID, for example:
Monitor the
stackstate.log
using the function instance ID.
Add logging statements to a function
Logging statements can be added to StackState functions and monitored in the stackstate.log
file. This is useful for debug purposes.
Add a log statement in the function's code. For example:
log.info("message")
log.info(variable.toString())
Set a logging level to enable logging for an instance of the function.
Find the ID for a function instance
Retrieve the ID for a specific instance of a function:
StackState CLI
Event handler IDs
The ID for an event handler can be found using the StackState CLI. This is the ID for an instance of an event handler function.
To list all event handlers, run the StackState CLI command below.
Use the
id
from the command output to enable logging for a specific event handler.
View health state configuration IDs
The ID for a view health state configuration can be found using the StackState CLI. This is the ID for a view's instance of a view health state configuration function.
Run the two StackState CLI commands below:
To return the IDs of all StackState views.
To retrieve the JSON for a specific view ID.
Use the
viewHealthStateConfiguration
ID from the retrieved view JSON to enable logging for this instance of the view health state configuration function. In the example below, this would be39710412772194
.
StackState UI
Check and propagation IDs
The ID for a check or propagation on a specific component can be found in in the StackState UI. These are the IDs for the component's instance of a check function or propagation function.
Click on a component to open the component details on the right of the screen.
Click on ... and select Show JSON.
Find the section for
"checks"
or"propagation"
.Find the check or propagation that you want to enable logging for and copy the value from the field
id
.
![](https://docs.stackstate.com/~gitbook/image?url=https%3A%2F%2F3924373518-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fgp1QbEIpZmjYpV6PbJha%252Fuploads%252Fgit-blob-e91031ada642fda3502f22263f6b6dad92037b9a%252Fv46_show-json.png%3Falt%3Dmedia%26token%3D4e5810d4-ec83-4a38-b6d0-d7534beca7ee&width=768&dpr=4&quality=100&sign=1ace4962&sv=1)
Use the ID to enable logging for the component's check or propagation functions.
See also
Last updated