Published On: 13 April 2013Last Updated: 13 April 2013

Metalog is an easily configurable system logger daemon which can be substituted for standard syslogd and klogd. It has one limitation though, that you cannot log to remote machines. It’s very easy to configure Nginx to use Syslog (Metalog, in my case).

All you need to do is compile nginx with this syslog plugin. If you’re on Gentoo, you can compile nginx with the syslog useflag.
Configure nginx as follows:

# global section

syslog local0;
error_log syslog;

# http

http {
   access_log syslog:info <format>;
}

And then, metalog configuration:

Nginx Access:
    facility = "local0"
    logdir = "/var/log/nginx/access"    
    minimum = 6
    break = 1

Nginx Errors:
    facility = "local0"
    logdir = "/var/log/nginx/errors"    
    maximum = 4
    break = 1

This configuration must be placed before catch-all rule otherwise, you’ll have all errors and access logs in your /var/log/everything/current which is quite disturbing.

With this configuration, you can find nginx logs at /var/log/nginx/errors/current  and /var/log/nginx/access/current .

The advantage? Metalog performs automatic log rotation. Yes, I know I can configure a cron job for that, but I prefer this.

Consider sharing your thoughts about what you read

Share

Get new posts by email