Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ユーザー定義のLogRecord属性
# もちろん必要部分は書いてください
# 説明上formatだけ記述します。
......................
[formatter_hogehogeFormatter]
format=%(asctime)s%(tab)s%(hostname)s%(tab)s%(user)s%(tab)s%(message)s
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
You can’t perform that action at this time.