Last active
August 26, 2021 07:14
-
-
Save bootandy/5546891 to your computer and use it in GitHub Desktop.
Sample logging config file for python logging module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use with: logging.config.dictConfig(yaml.load(open('logging.yaml', 'r'))) | |
# Formatters detailed here: http://docs.python.org/2/library/logging.html#logrecord-attributes | |
version: 1 | |
formatters: | |
simple: | |
format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s' | |
detail: | |
format: '%(asctime)s - %(levelname)s - File: %(filename)s - %(funcName)s() - Line: %(lineno)d - %(message)s' | |
loggers: | |
all: | |
handlers: [all] | |
propagate: true | |
warn: | |
handlers: [warn] | |
propagate: true | |
ingenia: | |
handlers: [ingenia] | |
propagate: false # We dont want ingenia logs going everywhere | |
qualname: ingenia | |
tornado: | |
handlers: [all] | |
propagate: false | |
handlers: | |
console: | |
class: logging.StreamHandler | |
level: INFO | |
formatter: simple | |
stream: ext://sys.stdout | |
all: | |
class: logging.handlers.TimedRotatingFileHandler | |
level: INFO | |
formatter: simple | |
when: W0 | |
backupCount: 4 | |
filename: /var/log/grata/all.log | |
warn: | |
class: logging.handlers.TimedRotatingFileHandler | |
level: WARNING | |
formatter: detail | |
when: W0 | |
backupCount: 4 | |
filename: /var/log/grata/warn.log | |
ingenia: | |
class: logging.handlers.TimedRotatingFileHandler | |
level: DEBUG | |
formatter: simple | |
when: W0 | |
backupCount: 4 | |
filename: /var/log/grata/ingenia.log | |
root: | |
level: INFO | |
handlers: [console, all, warn] | |
propagate: true |
What about configure filename in TimedRotatingFileHandler? In code i can add in end time or date in filename. For example: handler = handlers.TimedRotatingFileHandler('config.log'+datetime.datetime.now().strftime('%d-%m-%Y'), when='midnight')
How i can do this in config file?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried but didn't log access records of tornado. Why?