Last active
October 17, 2017 09:27
-
-
Save suganoo/49888a18d1c250d2813ae3331489f067 to your computer and use it in GitHub Desktop.
ユーザー定義のLogRecord属性
This file contains 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
# もちろん必要部分は書いてください | |
# 説明上formatだけ記述します。 | |
...................... | |
[formatter_hogehogeFormatter] | |
format=%(asctime)s%(tab)s%(hostname)s%(tab)s%(user)s%(tab)s%(message)s |
This file contains 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
import logging | |
import logging.config | |
logging.config.fileConfig("logging_formatter.conf") | |
hogelogger = logging.getLogger("hogehoge") | |
# このdictionaryが必要! | |
extra_args = {} | |
extra_args['tab'] = "\t" | |
extra_args['hostname'] = "hogehogeserver" | |
extra_args['user'] = "fugafugauser" | |
# ここが大事!!! | |
hogelogger.info(output, extra=extra_args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment