How can I keep only the last week of error logs?

Follow

As of the 4.0 release, AMPS does not provide a way to automatically delete error logs.  However, you can 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: 

...

<Actions>
  <Action>
    <On>
     <Module>amps-action-on-schedule</Module>
<Options>
<Every>00:00</Every>
</Options>
</On>
<Do>
<Module>amps-action-do-rotate-logs</Module>
<Options>
<Age>10s</Age>
</Options>
</Do>
</Action>
</Actions>
<Logging> <Target> <Protocol>file</Protocol> <!-- Log files uses the day of the week in the format, so: AMPS-InstanceName-Friday.log --> <FileName>./logs-dest/AMPS-InstanceName-%A.log</FileName> <Level>info</Level> </Target> </Logging>

...  

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.

 

 

keywords: log rotation, log size, AMPS maintenance

Have more questions? Submit a request

Comments

Powered by Zendesk