logging.basicConfig()詳細
1977 ワード
logging.basicConfig(**kwargs)
この関数は、デフォルトのFormatter
を持つStreamHandler
を作成し、ルート・ログ・レコーダに追加することによって基本構成を初期化します.ルートログレコーダがプロセッサを定義していない場合、debug()
、info()
、warning()
、error()
and critical()
は、basicConfig()
を自動的に呼び出します.ルート・ログ・レコーダがプロセッサを構成している場合は、この関数は機能しません.この関数は、プライマリ・スレッドで呼び出され、他のスレッドが開始される前に呼び出されます.Python 2.7.1と3.2の前に、この関数はマルチスレッドによって呼び出されます.ルート・ログ・レコーダにプロセッサが複数回追加される可能性があり、ログ内の情報の重複などの予期せぬ結果が発生します.
次のキーワードパラメータをサポートします.
書式設定
説明
filename
説明StreamHandlerではなくfilenameというFileHandlerを作成しました
filemode
filenameパラメータが指定する場合、このモードはオンで、デフォルトは
'a'
です.format
指定した文字列フォーマットの使用
datefmt
time.strftime()
で指定された日付/時刻フォーマットを使用style
If format is specified, use this style for the format string. One of
'%'
, '{'
or '$'
for printf-style, str.format()
or string.Template
respectively. Defaults to '%'
. level
ルート・ログ・レコーダ・レベルの指定
stream
Use the specified stream to initialize the StreamHandler. Note that this argument is incompatible with filename - if both are present, a
ValueError
is raised. handlers
If specified, this should be an iterable of already created handlers to add to the root logger. Any handlers which don’t already have a formatter set will be assigned the default formatter created in this function. Note that this argument is incompatible with filename or stream - if both are present, a
ValueError
is raised.