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:
<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 theeffective logger levelis set toDEBUGorTRACE.
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.
stackTraceSuppressByLoggerLevel flag to false to capture all stack traces globally.
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, andtotalSizeCap. - To increase retention, increase
maxHistoryand adjusttotalSizeCapproportionally to accommodate the additional files.
Best Practices
- Back Up: Always create a copy of your current
logback.xmlbefore 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.
stackTraceSuppressByLoggerLevelset totrue.- Set the root logger to
INFO. - Enable
DEBUGonly for specific packages as required. - Maintain strictly bounded rotation settings (
maxFileSize,maxHistory, andtotalSizeCap).