Why is the logwatch conf with absolute paths LogFile entries not working

logwatch

The logwatch documentation says the LogFile command can handle absolute paths. Accordingly, I have a celery.conf file in /etc/logwatch/conf/services as follows:

Title = "Watchdog Celery worker errors"
LogFile = /var/log/208-celery.log
LogFile = /var/log/234-celery.log
LogFile = /var/log/403-celery.log
LogFile = /var/log/dev-celery.log 

(The intention is for the four specified log files to be combined into a single group for logwatch.)

I get this error:

*** Error: There is no logfile defined. Do you have a /etc/logwatch/conf/logfiles//var/log/208-celery.log.conf file ?
*** Error: There is no logfile defined. Do you have a /etc/logwatch/conf/logfiles//var/log/234-celery.log.conf file ?
*** Error: There is no logfile defined. Do you have a /etc/logwatch/conf/logfiles//var/log/403-celery.log.conf file ?
*** Error: There is no logfile defined. Do you have a /etc/logwatch/conf/logfiles//var/log/dev-celery.log.conf file ?
Can't open: /usr/share/logwatch/scripts/services/celery at /usr/sbin/logwatch line 1329.

It seems like logwatch is not interpreting the LogFile commands as absolute paths for some reason. I have confirmed those log files definitely exist at those paths. As for the "Can't open…" error — my guess is that logwatch is looking for a default configuration due to the lack of working LogFile commands.

So: how do I get logwatch to correctly watch those specific log files?

NOTE: I'm using logwatch v7.4.0 running on Ubuntu 12.04.4 LTS.

Best Answer

The LogFile entries in the config files under services refer to logfile groups which are defined in the corresponding config file under logfiles. See section A of the document you linked to for info about configuring a logfile group ...

# This will be the logfile named 'messages' in the default logfile # directory (probably /var/log). LogFile = messages

# You can also give this command with an absolute path, like this: LogFile = /var/log/messages

And section B for referring to these groups in a config file under services ...

For a service filter that needs messages from /var/log/messages you would add this line:

LogFile = messages

NOTE: This is not because the name of the logfile is 'messages', but it is because the name of the LogFile Group that has been defined is 'messages'.

The error /usr/share/logwatch/scripts/services/celery is because you haven't created a service filter executable as described in section C of the document. You should create this (using the example script) under /etc/logwatch/scripts/services making sure that it is executable. I've just tried this (logwatch 7.4.0 on CentOS 7.2 and it works as expected.

Related Topic