views:

92

answers:

1

Hi

Can anyone please suggest how to generate log files having following directory-file structure using python logging in django project.

logs/2009-03-09 
          /errors.log
          /warnings.log
          /info.log
          /emails.log
          /messages.log

logs/2009-03-08 
          /errors.log
          /warnings.log
          /info.log
          /emails.log
          /messages.log
+2  A: 
  1. Set up FileHandler instances with Filter instances which match the criteria for those files.
  2. Add the handlers to the root logger.
  3. Profit ;-)

See this other answer for an example of a filter which matches a specific level. You can use that as an example to create your own custom filters for 'emails' and 'messages' logs.

Use strftime to format the paths with dates in them.

Vinay Sajip