Stack Trace Guidelines for Logs

Configure stack trace verbosity and log rotation settings in logback.xml for on-premises logs.

This topic explains how to manage stack trace verbosity and log rotation policies within your on-premises environment using logback.xml. Proper configuration ensures efficient troubleshooting while maintaining optimal disk usage.

You can control the inclusion of stack traces in your logs using the stackTraceSuppressByLoggerLevel property. This setting applies to both JSON logs and legacy text logs.

Set the property within the context scope:

CODE
<property scope="context" name="stackTraceSuppressByLoggerLevel" value="[true/false]"/>
  • false: Logs stack traces for all exceptions, regardless of the logger level.
  • true: Logs stack traces only when the effective logger level is set to DEBUG or TRACE.
Note: Stack trace gating is determined by the effective logger level, not the event level. For example, if an ERROR event occurs but the logger is set to INFO, the stack trace will be suppressed when the flag is true.

Enable Stack Traces for Troubleshooting

Set the stackTraceSuppressByLoggerLevel flag to true and enable DEBUG only for the specific package under investigation. This reduces noise while capturing the necessary details.

Enable Stack Traces for Triaging Incidents.

For critical incident triage, set the stackTraceSuppressByLoggerLevel flag to false to capture all stack traces globally.
Important:

The incident setting can increase log volume significantly. Revert this setting to true immediately to avoid excessive log volume.

Configure Log Rotation

Configure your log rotation using the following parameters:

Parameter Description
maxFileSize The maximum size allowed for a single log file before the log file rolls over.
maxHistory The number of rollover periods to retain archived logs.
totalSizeCap The hard limit for the total size of all archived logs.
  • To reduce disk usage, decrease maxFileSize, maxHistory, and totalSizeCap.
  • To increase retention, increase maxHistory and adjust totalSizeCap proportionally to accommodate the additional files.

Best Practices

Follow these best practices to ensure system stability when modifying logging configurations:
  • Back Up: Always create a copy of your current logback.xml before applying changes.
  • Make Incremental Changes: Modify only one setting type at a time, such as flag settings, logger levels, or rotation parameters.
  • Validate: After applying changes, monitor the log volume and disk growth to ensure they align with your expectations.
  • Revert: Always revert temporary Incident Mode settings once troubleshooting is complete.
For standard operations, use the following settings.:
  • stackTraceSuppressByLoggerLevel set to true.
  • Set the root logger to INFO.
  • Enable DEBUG only for specific packages as required.
  • Maintain strictly bounded rotation settings (maxFileSize, maxHistory, and totalSizeCap).