5

I am logging all our applications logs to /logs/, where all our applications have an seperate directory. I have made a custom logrotate file as follows:

/logs/*.log {
    daily
    missingok
    rotate 1
    sharedscripts
    dateext
}

So this is catching all logfiles within /logs. But i want to leave some directories out of the rotation. Can I somehow exclude these directories? And what would be the best practice in this situation?

julienc
  • 203
  • 3
  • 11
Tom
  • 63
  • 1
  • 1
  • 4

4 Answers4

5

The recommended location for log files is /var/log.

You can do some file globbing and multiple filespecs to specify what to include:

/var/log/appone.log
/var/log/app[2-7].log
/var/log/other*.log
{
    log options
}

but it's better to create different files for each app and put them in /etc/logrotate.d and include only one or two filespecs in each that are associated in some way (e.g. app or function/purpose). Use the existing files in that directory as models.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
0

Use wildcards sparingly. If I were you, I'd specify the logfiles of each application separately.

ptman
  • 28,394
  • 2
  • 30
  • 45
0

Short of doing evil glob syntax I don't think there's any obvious way.

The best way would be to switch to a conf file per app.

LapTop006
  • 6,496
  • 20
  • 26
0

You can use globbing to do this: http://manpages.ubuntu.com/manpages/jaunty/en/man7/glob.7.html

Sietse
  • 497
  • 5
  • 13