0
0

More than 1 year has passed since last update.

python loggingモジュール

Posted at

1 概要

既存システムのロギングの改修

(1) 既存システム

(ⅰ) WEBアプリケーション  
(ⅱ) 同一ソースコードで2つのプロセス(workerではない)が動いている
(ⅲ) 2つのプロセスは同じログファイルに出力される。
(ⅳ) ログローテートされていない。

(2) 改修ポイント

①[(1) 既存システム]の(ⅲ)について
 ⇒別々のログファイルに出力する。

②[(1) 既存システム]の(ⅳ)について
 ⇒ログローテーションを実施。

(3) 実装

[(2) 改修ポイント]の①について
 ⇒プログラム起動時に別々の設定ファイルを読み込む設定を処理に修正。

[(2) 改修ポイント]の②について
 ⇒ログローテート間隔のバックアップ数はログ設定ファイルで対応可能
 ⇒圧縮処理は別途実装が必要となる。

使用するロギングクラス
TimedRotatingFileHandler
https://docs.python.org/ja/3/library/logging.handlers.html?highlight=logging%20handler#timedrotatingfilehandler

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0