logger 제작시 문제점 본문

Programming

logger 제작시 문제점

halatha 2013. 1. 23. 14:08

http://docs.python.org/2/howto/logging-cookbook.html

http://docs.python.org/2/library/logging.handlers.html#module-logging.handlers

http://www.red-dove.com/python_logging.html


handler: google 'python logger multiple handler'

http://stackoverflow.com/questions/2031394/python-logging-over-multiple-files


submodule도 main과 같은 logger 사용: google 'python global logger'

http://stackoverflow.com/questions/7621897/python-logging-module-globally

python의 package __init__.py에서 initialization을 하면 Singleton처럼 동작하는 걸까?

기본적으로는 root logger를 사용해도 각 main을 갖는 module은 별도의 파일에 저장할 수 있으므로(root logger가 각 python interpreter마다 생성되므로) submodule에서는 그냥 logging.getLogger()로 불러다 써도 된다


stop root logger's standard output

http://stackoverflow.com/questions/2266646/how-to-i-disable-and-re-enable-console-logging-in-python

logging.getLogger().removeHandler(logging.getLogger().handlers[0]) # remove standard output handler

logging.getLogger().addHandler(...)


custom string format: google 'python logRecord subclass' 'python logging Formatter subclass' 'python makeLogRecord example' 'custom format function for python logging'

http://plumberjack.blogspot.kr/2010/12/getting-more-control-over-logrecord.html

http://stackoverflow.com/questions/6692248/python-logging-string-formatting

format string을 설정


duplicated log message: google 'python logger duplicated'

http://stackoverflow.com/questions/7173033/duplicate-log-output-when-using-python-logging-module

http://stackoverflow.com/questions/8973698/trouble-with-duplicate-lines-of-logs-in-log-file

http://stackoverflow.com/questions/11666566/python-loggeradapter-is-making-duplicate-log-entries-to-stdout

logging.getLogger('...').propagate = False


string 대신 dict를 log 출력 인자로 사용: google 'python logger with dict args' 'python logging key value message'

http://code.activestate.com/recipes/577448-easy-logging-with-extras/

http://jedp.posterous.com/print-like-args-for-the-python-logger

http://code.activestate.com/recipes/474089-extending-the-logging-module/

사용하면 나쁠 것은 없지만 굳이 필요하지는 않은 기능


rotating log

RotatingFileHandler를 상속해, 실행 시마다 rollover를 하는 custom handler 제작

http://stackoverflow.com/questions/11379585/simple-rotating-python-logger-rotatingfilehandler


Subclassing logging related class: google 'python logRecord subclass'

http://jedp.posterous.com/print-like-args-for-the-python-logger

http://stackoverflow.com/questions/6692248/python-logging-string-formatting


Changing loggers on demand

http://stackoverflow.com/questions/14388929/changing-loggers-on-demand


how python logging module works

http://www.shutupandship.com/2012/02/how-python-logging-module-works.html

Comments