Suggestions required for generating this logging file structure in django project

試著忘記壹切 提交于 2020-01-05 04:29:28

问题


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

回答1:


  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.



来源:https://stackoverflow.com/questions/2408800/suggestions-required-for-generating-this-logging-file-structure-in-django-projec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!