logging: handle everything EXCEPT certain loggers
Jean-Michel Pichavant
jeanmichel at sequans.com
Mon Nov 7 08:39:17 EST 2011
Gábor Farkas wrote:
> hi,
>
> is there a way to setup log-handlers in a way that they log logs from
> every logger, exept certain ones?
>
> basically i want the handler to handle everything, except log-records
> that were generated by loggers from "something.*"
> can this be done?
>
> i tried to create filters, but the log-record does not have access to
> his logger, so i cannot filter based on it's "path".
>
> right now the only idea i have is to setup a filter for the
> "something.*" path, have it mark somehow the log-records,
> and then create a filter on the global level, that will drop such
> log-records. is there a simpler solution?
>
> thanks,
> gabor
>
Are you sure ?
LogRecord objects have a name attribute. You could do something like
return 'IdontWantYou' not in record.name
in your filter.
JM
More information about the Python-list
mailing list