I'm a newbie to Logwatch and have it set up to watch log files created by celery, a distributed task queue popular in the Python world.

My logwatch.conf "Range" is set to "between yesterday 4am and today 4am” and this range filter works for other log files -- but it's not working for my celery log files.

This is my setup:


Title = "Celery worker errors"
LogFile = celery


LogFile = /var/log/208-celery.log
LogFile = /var/log/234-celery.log
LogFile = /var/log/403-celery.log
LogFile = /var/log/dev-celery.log



It seems the problem is the just using cat as the filter -- obviously that is not filtering any date, just passing through the lines of the celerry log files.

I know logwatch has some built-in date format filters, but I'm not clear how to apply them, nor whether any of them fit the format of celery logs, which look like this:

[2016-04-26 11:59:37,851: WARNING/MainProcess] celery@big-dog ready.
[2016-04-26 11:59:37,852: DEBUG/MainProcess] | Worker: Hub.register Pool...
[2016-04-26 11:59:37,852: DEBUG/MainProcess] basic.qos: prefetch_count->16
[2016-04-26 11:59:43,146: INFO/MainProcess] Received task: hello_world[b29ef98a-d9fb-4cc6-b7db-9434a9bcc1e2]

My question is: how do I configure logwatch to correctly date-filter these log files?


I think /usr/share/logwatch/scripts/shared/applyhttpdate file would be helpful.

Define the date format for celery.


use Logwatch ':dates';

$Debug = $ENV{'LOGWATCH_DEBUG'} || 0;

$SearchDate = TimeFilter('%Y-%m-%d %H:%M:%S');

if ( $Debug > 5 ) {
   print STDERR "DEBUG: Inside ApplyCeleryDate...\n";
   print STDERR "DEBUG: Looking For: " . $SearchDate . "\n";

while (defined($ThisLine = <STDIN>)) {
   if ($ThisLine =~ m/\[$SearchDate/o) {
      print $ThisLine;

And, link the log file to the date format.


LogFile = /var/log/208-celery.log
LogFile = /var/log/234-celery.log
LogFile = /var/log/403-celery.log
LogFile = /var/log/dev-celery.log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.