I want my logs sent to my mail with logrotate

Posted by lericson on Server Fault See other posts from Server Fault or by lericson
Published on 2010-04-11T06:33:13Z Indexed on 2010/04/11 8:33 UTC
Read the original article Hit count: 311

Filed under:
|
|

Not strictly a question about programming as such, more of a log handling question.

Anyway. My company has multiple clients, and each of these clients have a set of logs that I'd rather much want to get sent to by e-mail to me.

Now, another prerequisite is that they're hilighted by simple HTML.

All that is very well, I've managed to make a hilighter for the given log types. So, what I do is I use logrotate's prerotate stuff to send the logs as an e-mail message. Example:

/var/log/a.log /var/log/b.log {
  daily
  missingok
  copytruncate

  prerotate
    /usr/bin/python /home/foo/hilight_logs /var/log/{a,b}.log | /usr/sbin/sendmail -FLog\ mailer [email protected] [email protected]
  endscript
}

The problem with this approach is basically that logrotate sucks: it'll run the command for every log file specified in the specifier, and to my knowledge there's no way to know which of the log files is being handled. (Which wouldn't really help anyway.)

Short of repeating the exact same logrotate up to 10 times on different machines, the only thing I can do is just to get bogged down with log spam every night. And I grew tired of it today, so I ask.

© Server Fault or respective owner

I want my logs sent to my mail with logrotate

Posted by lericson on Stack Overflow See other posts from Stack Overflow or by lericson
Published on 2010-04-11T06:33:13Z Indexed on 2010/04/11 6:43 UTC
Read the original article Hit count: 311

Filed under:
|
|

Not strictly a question about programming as such, more of a log handling question.

Anyway. My company has multiple clients, and each of these clients have a set of logs that I'd rather much want to get sent to by e-mail to me.

Now, another prerequisite is that they're hilighted by simple HTML.

All that is very well, I've managed to make a hilighter for the given log types. So, what I do is I use logrotate's prerotate stuff to send the logs as an e-mail message. Example:

/var/log/a.log /var/log/b.log {
  daily
  missingok
  copytruncate

  prerotate
    /usr/bin/python /home/foo/hilight_logs /var/log/{a,b}.log | /usr/sbin/sendmail -FLog\ mailer [email protected] [email protected]
  endscript
}

The problem with this approach is basically that logrotate sucks: it'll run the command for every log file specified in the specifier, and to my knowledge there's no way to know which of the log files is being handled. (Which wouldn't really help anyway.)

Short of repeating the exact same logrotate up to 10 times on different machines, the only thing I can do is just to get bogged down with log spam every night. And I grew tired of it today, so I ask.

© Stack Overflow or respective owner

Related posts about logrotate

Related posts about sysadmin