Am Freitag, 11. September 2015 11:03:52 UTC+2 schrieb jmp: > On 09/11/2015 09:22 AM, Thomas Güttler wrote: > > > > I want INFO to be logged and stored on the remote host. > > Therefore I must not filter INFO messages. > > > > I don't want to pull INFO messages over the VPN. > > > > Ergo, the filtering at Python level does not help in my use case. > > Or I am missing something. > > Probably, > > Your logger should have > > * a remote host handler > * and a VPN handler. > > You can set filters and log levels separately for each handler. > More info here > https://docs.python.org/2/library/logging.html#handler-objects > https://docs.python.org/2/howto/logging-cookbook.html#logging-to-multiple-destinations > > Something like (python 2.7) > > import logging > > logCfg = { > 'remote':( > logging.StreamHandler(), > logging.Formatter('Remote - %(levelname)s - %(message)s'), > logging.INFO, > ), > 'vpn':( > logging.StreamHandler(), > logging.Formatter('VPN - %(levelname)s - %(message)s'), > logging.ERROR, > ), > }
.... Yes, I could do it this way. But somehow I am not happy with this solution. I think the filtering should be outside of python. I like DevOp, but sometimes clear responsibilities help to cut big problems into smaller ones. I would like to handle the log message filtering outside of python. Can you understand my concerns? Thomas Güttler -- https://mail.python.org/mailman/listinfo/python-list