public class DateRotatePolicy extends java.lang.Object implements RotatePolicy
プロパティファイルの記述ルールを下記に示す。
次回ローテーション日時は、システム起動時とローテーション時に算出する。 計算方法は以下の通り。
まず、次回ローテーション日時を決めるための基準日時を決定する。 基準日時は、システム起動時かつログファイルが既に存在する場合とそれ以外の場合で以下の2通りの日時を採用する。
次に、基準日時の時刻と rotateTime の時刻を比較して、次回ローテーション日時の日付を決定する。
この日付に rotateTime の時刻を設定したものを、次回ローテーション日時とする。
   例えば、rotateTimeに 12:00:00 が設定されており、基準日時が 2023-03-25 11:59:59 の場合、
   次回ローテーション日時は 2023-03-25 12:00:00 となる。
   rotateTimeに 12:00:00 が設定されており、基準日時が 2023-03-25 12:00:01 の場合、
   次回ローテーション日時は 2023-03-26 12:00:00 となる。
 
ローテーション後のログファイル名は、 <ログファイルパス>.yyyyMMddHHmmssSSS.old となる。 yyyyMMddHHmmssSSSにはローテーション実施時刻が出力される。
| Constructor and Description | 
|---|
DateRotatePolicy()  | 
| Modifier and Type | Method and Description | 
|---|---|
protected java.util.Date | 
currentDate()
現在日時を返す。 
 | 
java.lang.String | 
decideRotatedFilePath()
ローテーション先のファイル名を決定する。 
 | 
java.lang.String | 
getSettings()
ログファイル読み込み時に出力する、ローテーションの設定情報を返す。 
 | 
void | 
initialize(ObjectSettings settings)
初期処理を行う。 
 | 
boolean | 
needsRotate(java.lang.String message,
           java.nio.charset.Charset charset)
ローテーションが必要かの判定を行う。 
 | 
void | 
onOpenFile(java.io.File file)
ログファイル読み込み時に発生するイベント。 
ファイルサイズによるローテーションなどを独自で実装したい場合に使用する。  | 
void | 
onWrite(java.lang.String message,
       java.nio.charset.Charset charset)
ログファイル書き込み時に発生するイベント。 
ファイルサイズによるローテーションなどを独自で実装したい場合に使用する。  | 
void | 
rotate(java.lang.String rotatedFilePath)
ローテーションを行う。 
 | 
public void initialize(ObjectSettings settings)
initialize in interface RotatePolicysettings - LogWriterの設定public boolean needsRotate(java.lang.String message,
                           java.nio.charset.Charset charset)
needsRotate in interface RotatePolicymessage - ログファイルに書き込まれるメッセージcharset - 書き込み時に使用する文字エンコーディングpublic java.lang.String decideRotatedFilePath()
decideRotatedFilePath in interface RotatePolicypublic void rotate(java.lang.String rotatedFilePath)
rotate in interface RotatePolicyrotatedFilePath - ローテーション先のファイルパスjava.lang.IllegalStateException - ログファイルのリネームができない場合public java.lang.String getSettings()
 
 ROTATE TIME         = [<ローテーション時刻>]
 NEXT ROTATE DATE    = [<次回ローテーション日時>]
 CURRENT DATE        = [<現在時刻>]
 
 getSettings in interface RotatePolicyFileLogWriter.getSettings()protected java.util.Date currentDate()
public void onWrite(java.lang.String message,
                    java.nio.charset.Charset charset)
onWrite in interface RotatePolicymessage - ログファイルに書き込まれるメッセージcharset - 書き込み時に使用する文字エンコーディングpublic void onOpenFile(java.io.File file)
onOpenFile in interface RotatePolicyfile - 読み込まれたファイル