XRAY: How to Reduce Xray Log Volume and Configure Log Rotation
Overview
If your Xray deployment is generating a large volume of log data, you can reduce the amount of logging by adjusting the application log level and configuring log rotation.
Reduce Log Volume
To reduce the amount of logging generated by an Xray service, configure the application log level in the relevant section of the system.yaml file.
For example:
persist:
logging:
application:
level: error
Supported log levels are:
- error
- warning
- info (default)
- debug
- trace
Setting the log level to error logs only error messages and significantly reduces log volume.
Apply the same configuration to any Xray service as needed (server, analysis, indexer, persist, policyenforcer, and others).
Configure Log Rotation
To prevent application log files from growing indefinitely, configure log rotation under the application section. By setting the log file max size and the number of files in the system.yaml file. For instance, this example sets the max size to 25MB and the max number of files to 10:
Example:
persist:
logging:
application:
level: error
rotation:
compress: true
maxSizeMb: 25
maxFiles: 10|
Parameter |
Description |
|
compress |
Compresses rotated log files. |
|
maxSizeMb |
Maximum size of a log file before rotation occurs. |
|
maxFiles |
Maximum number of rotated log files to retain. |
Configure the same settings for any Xray service whose logs you want to manage.
Apply the Changes
After updating system.yaml, restart Xray for the new logging configuration to take effect.
Best Practices
- Keep the default info log level unless you need to reduce log volume.
- Use error only when detailed informational logs are not required.
- Configure log rotation to prevent excessive disk usage instead of disabling logging.