Last active
January 17, 2019 09:45
-
-
Save 0x49D1/584d0926fde8b6da1da879ae6021e542 to your computer and use it in GitHub Desktop.
Sample of python logging configuration with log to stdout (console) and syslog
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
[loggers] | |
keys=root, gunicorn.error, gunicorn.access, requests.packages.urllib3.connectionpool, __main__ | |
[handlers] | |
keys=log_file, syslog | |
[formatters] | |
keys=generic | |
[logger_root] | |
level=INFO | |
handlers=log_file, syslog | |
[logger___main__] | |
level=DEBUG | |
handlers=log_file, syslog | |
propagate=0 | |
qualname=__main__ | |
[logger_gunicorn.error] | |
level=INFO | |
handlers=log_file, syslog | |
propagate=0 | |
qualname=gunicorn.error | |
[logger_gunicorn.access] | |
level=INFO | |
handlers=log_file, syslog | |
propagate=0 | |
qualname=gunicorn.access | |
[logger_requests.packages.urllib3.connectionpool] | |
level=WARN | |
handlers=log_file, syslog | |
propagate=0 | |
qualname=requests.packages.urllib3.connectionpool | |
[handler_syslog] | |
class=logging.handlers.SysLogHandler | |
formatter=generic | |
level=DEBUG | |
args=('/dev/log',handlers.SysLogHandler.LOG_USER) | |
[handler_log_file] | |
class=logging.FileHandler | |
formatter=generic | |
args=('/var/log/gunicorn.log',) | |
[formatter_generic] | |
format=%(asctime)s [%(process)d:%(name)s:%(lineno)s] [%(levelname)s] %(message)s | |
datefmt=%Y-%m-%d %H:%M:%S | |
class=logging.Formatter |
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
[loggers] | |
keys=root | |
[handlers] | |
keys=stream_handler, syslog_handler | |
[formatters] | |
keys=formatter | |
[logger_root] | |
level=DEBUG | |
handlers=stream_handler, syslog_handler | |
[handler_stream_handler] | |
class=StreamHandler | |
level=DEBUG | |
formatter=formatter | |
args=(sys.stdout,) | |
[handler_syslog_handler] | |
class=logging.handlers.SysLogHandler | |
level=DEBUG | |
formatter=formatter | |
args=('/dev/log',handlers.SysLogHandler.LOG_USER) | |
[formatter_formatter] | |
format=%(asctime)s tid:%(thread)-10s %(threadName)-12s %(name)-12s %(levelname)-8s %(message)s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment