Nginx and Metalog

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:

And then, metalog configuration:

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.

Have something to add? Do it here.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑

%d bloggers like this: