How can I keep only the last week of error logs?
There are a number of ways to do this.
The most common way to do this is to configure an action that runs on a regular schedule and invokes amps-action-do-remove-files to remove error logs that are older than 7 days. For example, if the application logs to ${AMPS_MONITORING}/logs
with file names that end in .log
, you could configure an action like the following to run every night at 30 minutes after midnight (local time for the server):
Another approach is to use the log rotation action to rotate logs and create a file name specification that ensures that AMPS only keeps logs for the last 7 days.
Here's how to use these features together:
Create an action that rotates the log every day (typically, at midnight)
Specify a filename pattern for the log files that repeats every week
With these two configuration options in place, the effect is that AMPS will create a different log file each day, and reuse the same log file once every week.
The sample configuration below demonstrates how to do this:
Notice that the configuration above doesn't set a RotationThreshold
for the log. Instead, the log is allowed to grow until the Action
rotates it once a day.
Last updated