The nsqcirclog utility provides circular logging for the nsqmq agent, as well as for Connection Manager (CM) and EMS. It helps prevent disk space issues when running the agent in trace mode by rotating log files.
How does nsqcirclog work?
It writes agent output to a log file. Once the file reaches a set number of lines, it rotates the log by renaming the old file (e.g., XX becomes XX.1) and creating a new log file. This keeps the number of logs within a specified limit.
What options can you set with nsqcirclog?
- -ln <number>: Set the maximum number of lines per log file (default: no limit).
- -fn <number>: Set the maximum number of log files to retain (default: no limit).
- -filename <filepath>: Specify the log file name.
Example usage
nsqmq -mMQM -s5011 | nsqcirclog -ln 200 -filename /opt/nastel/apwmq/logs/nsqmq.log &
When nsqcirclog reaches the maximum number of log files, it deletes the oldest log file and renames the current log file. This ensures the utility maintains the specified number of log files.
If you don't set limits for file size or the number of log files, nsqcirclog will continue writing to the log file, potentially consuming more disk space over time. To prevent this, it's recommended to set limits.