[Grok-dev] Is it easy to create a custom log handler?
Sebastian Ware
sebastian at urbantalk.se
Fri Mar 26 17:01:49 EDT 2010
Big thanks! Now I know where to start. I found some exotic versions
when looking through the test of some eggs and this looks a lot more
manageable. :)
Mvh Sebastian
26 mar 2010 kl. 21.35 skrev Souheil CHELFOUH:
> from the top of my head something like :
>
> import logging
>
> def generate_logger(name):
> path = "/path/to/loggers_folder/%s.log" % name
> format = logging.Formatter("%(asctime)s - %(levelname)s - %
> (message)s")
>
> # preparing logging.
> logger = logging.getLogger(name)
> logger.setLevel(logging.INFO)
>
> # files tuning
> handler = logging.handlers.RotatingFileHandler(
> path, maxBytes=5000000, backupCount=10)
>
> handler.setFormatter(format)
> logger.addHandler(handler)
>
> return logger
>
>
>
> 2010/3/26 Sebastian Ware <sebastian at urbantalk.se>:
>> in order to keep z3.log clean I would like to create a custom.log
>> where I can log certain activities in my application. Stuff I don't
>> want to put in the database.
>>
>> I understand it such that I should create a custom logger to connect
>> to the python logging module. But is there any component in zope3 I
>> can use to set this up easily?
>>
>> Does anyone have some code samples?
>>
>> Mvh Sebastian
>>
>>
>> _______________________________________________
>> Grok-dev mailing list
>> Grok-dev at zope.org
>> https://mail.zope.org/mailman/listinfo/grok-dev
>>
More information about the Grok-dev
mailing list