lilspikey / django-background-task

A database-backed work queue for Django
BSD 3-Clause "New" or "Revised" License
107 stars 207 forks source link

Logging options do nothing if the root logger already has any handlers #2

Open slinkp opened 12 years ago

slinkp commented 12 years ago

You do your logging setup via logging.basicConfig(). As per the python docs: "This function does nothing if the root logger already has handlers configured for it."

So if I have logging configured for django via settings.LOGGING, I can't use the process_tasks logging options to override that. And confusingly, --log-file silently has no effect.

This is really problematic when running under cron if settings.LOGGING includes a stream handler, as you need to silence everything but errors on stdout/stderr to avoid having cron email you non-error output all the time.

Since process_tasks runs in its own process, maybe we should instead remove all handlers and add a file handler if and only if --log-file is provided?

lilspikey commented 12 years ago

Sounds like a plan.

I should probably review the logging, as I wrote most of it pre-1.3.

Hopefully I'll get a chance at the weekend to do this.