From logging to files to a better solution: syslog, Sentry, Logstash, ....

dieter dieter at handshake.de
Wed Sep 16 07:57:50 CEST 2015


Thomas Güttler <hv at tbz-pariv.de> writes:
> Am Freitag, 11. September 2015 11:03:52 UTC+2 schrieb jmp:
> ...
>> 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.

Do you think, it will be easier there?

You could also use the "syslog" handler and use "syslog"
configuration features to separate the various message levels.
>From my point of view, this will not be easier - but outside of Python :-)

And you can develop your own Python logging handler delegating logging to
your favorite external logging subsystem and then configure that.
Likely the hardest approach...



More information about the Python-list mailing list