org.apache.log4j
クラス FileAppender

java.lang.Object
  |
  +--org.apache.log4j.AppenderSkeleton
        |
        +--org.apache.log4j.WriterAppender
              |
              +--org.apache.log4j.FileAppender
すべての実装インタフェース:
Appender, OptionHandler
直系の既知のサブクラス:
DailyRollingFileAppender, RollingFileAppender

public class FileAppender
extends WriterAppender

FileAppender appends log events to a file.

FileAppender は、ログイベントをファイルに追加します。

Support for java.io.Writer and console appending has been deprecated and will be removed in the near future. You are strongly encouraged to use the replacement solutions: WriterAppender and ConsoleAppender.

java.io.Writerとコンソールの追加のサポートは、推奨されないので、近い将来削除されます。 あなたには、別の置き換えのきくソリューションを利用することを強く勧めます: WriterAppenderConsoleAppender があります。

作成者:
Ceki Gülcü

フィールドの概要
static String APPEND_OPTION
          推奨されていません。 We now use JavaBeans introspection to configure components. Options strings are no longer needed.

今日、私たちは、コンポーネントの設定では、JavaBeansのイントロスペクションを使っています。 オプション文字列は、今後、必要なくなります。

static String FILE_OPTION
          推奨されていません。 We now use JavaBeans introspection to configure components. Options strings are no longer needed.

今日、私たちは、コンポーネントの設定では、JavaBeansのイントロスペクションを使っています。 オプション文字列は、今後、必要なくなります。

protected  boolean fileAppend
          Append to or truncate the file?
protected  String fileName
          The name of the log file.
protected  boolean qwIsOurs
          推奨されていません。 FileAppender will not support streams passed by the user in the future.

FileAppender は、将来的には、ユーザにより渡されたストリームをサポートしない予定です。

 
クラス org.apache.log4j.WriterAppender から継承したフィールド
IMMEDIATE_FLUSH_OPTION, immediateFlush, qw
 
クラス org.apache.log4j.AppenderSkeleton から継承したフィールド
closed, errorHandler, headFilter, layout, name, tailFilter, threshold, THRESHOLD_OPTION
 
コンストラクタの概要
FileAppender()
          The default constructor does not do anything.
FileAppender(Layout layout, OutputStream os)
          推奨されていません。 The functionality of this constructor form has been replaced by the WriterAppender. This constructor will be removed in the near term.

コンストラクタのフォームの機能は、WriterAppenderにより置き換えられます。 このコンストラクタは、近いうちに削除される予定です。

FileAppender(Layout layout, String filename)
          Instantiate a FileAppender and open the file designated by filename.
FileAppender(Layout layout, String filename, boolean append)
          Instantiate a FileAppender and open the file designated by filename.
FileAppender(Layout layout, Writer writer)
          推奨されていません。 The functionality of constructor form has been replaced by the WriterAppender. This constructor will be removed in the near term.

コンストラクタのフォームの機能は、WriterAppenderにより置き換えられます。 このコンストラクタは、近いうちに削除される予定です。

 
メソッドの概要
 void activateOptions()
          If the value of FILE_OPTION is not null, then setFile(java.lang.String) is called with the values of FILE_OPTION and APPEND_OPTION.
protected  void closeFile()
          Closes the previously opened file.
 boolean getAppend()
          Returns the value of the Append option.
 String getFile()
          Returns the value of the File option.
 String[] getOptionStrings()
          推奨されていません。 We now use JavaBeans introspection to configure components. Options strings are no longer needed.

今日、私たちは、コンポーネントの設定には、JavaBeansのイントロスペクションを利用します。 オプション文字列は、今後必要なくなります。

protected  void reset()
          Close any previously opened file and call the parent's reset.
 void setAppend(boolean flag)
          The Append option takes a boolean value.
 void setFile(String file)
          The File option takes a string value which should be the name of the file to append to.
 void setFile(String fileName, boolean append)
          Sets and opens the file where the log output will go.
 void setOption(String key, String value)
          Set option to value.
protected  void setQWForFiles(Writer writer)
          Sets the quiet writer being used.
 
クラス org.apache.log4j.WriterAppender から継承したメソッド
append, checkEntryConditions, close, closeWriter, getImmediateFlush, requiresLayout, setErrorHandler, setImmediateFlush, setWriter, subAppend, writeFooter, writeHeader
 
クラス org.apache.log4j.AppenderSkeleton から継承したメソッド
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setLayout, setName, setThreshold
 
クラス java.lang.Object から継承したメソッド
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

FILE_OPTION

public static final String FILE_OPTION
推奨されていません。 We now use JavaBeans introspection to configure components. Options strings are no longer needed.

今日、私たちは、コンポーネントの設定では、JavaBeansのイントロスペクションを使っています。 オプション文字列は、今後、必要なくなります。

A string constant used in naming the option for setting the output file. Current value of this string constant is File.

出力ファイルを設定するためのオプションとして指定する時に使われる文字列定数です。 この文字列定数の現在の値は、Fileです。

Note that all option keys are case sensitive.

全てのオプションキーは、大文字と小文字の区別をするのに気をつけてください。


APPEND_OPTION

public static final String APPEND_OPTION
推奨されていません。 We now use JavaBeans introspection to configure components. Options strings are no longer needed.

今日、私たちは、コンポーネントの設定では、JavaBeansのイントロスペクションを使っています。 オプション文字列は、今後、必要なくなります。

A string constant used in naming the option that determines whether the output file will be truncated or appended to. Current value of this string constant is Append.

出力ファイルが追加されないか追加されるかどうかを判定するオプションを指定する時に使用する文字列定数です。 この文字列定数の現状の値は、Appendです。

Note that all option keys are case sensitive.

全てのオプションキーは、大文字と小文字の区別をするのに気をつけてください。


fileAppend

protected boolean fileAppend
Append to or truncate the file? The default value for this variable is true, meaning that by default a FileAppender will append to an existing file and not truncate it.

This option is meaningful only if the FileAppender opens the file.

このオプションは、FileAppenderがファイルをオープンしたかどうかだけを意図しています。


fileName

protected String fileName
The name of the log file.

qwIsOurs

protected boolean qwIsOurs
推奨されていません。 FileAppender will not support streams passed by the user in the future.

FileAppender は、将来的には、ユーザにより渡されたストリームをサポートしない予定です。

Is the QuietWriter ours or was it created and passed by the user?

QuietWriter が私たちのものか、ユーザにより作成され、渡されたものか?

コンストラクタの詳細

FileAppender

public FileAppender()
The default constructor does not do anything.

デフォルトのコンストラクタは、何も行いません。


FileAppender

public FileAppender(Layout layout,
                    OutputStream os)
推奨されていません。 The functionality of this constructor form has been replaced by the WriterAppender. This constructor will be removed in the near term.

コンストラクタのフォームの機能は、WriterAppenderにより置き換えられます。 このコンストラクタは、近いうちに削除される予定です。

Instantiate a FileAppender and set the output destination to a new OutputStreamWriter initialized with os as its OutputStream.

FileAppenderのインスタンスを生成し、OutputStreamとしてosを使って新規に初期化された OutputStreamWriterを出力先として設定します。


FileAppender

public FileAppender(Layout layout,
                    Writer writer)
推奨されていません。 The functionality of constructor form has been replaced by the WriterAppender. This constructor will be removed in the near term.

コンストラクタのフォームの機能は、WriterAppenderにより置き換えられます。 このコンストラクタは、近いうちに削除される予定です。

Instantiate a FileAppender and set the output destination to writer.

FileAppenderのインスタンスを生成し、writerを出力先として設定します。

The writer must have been opened by the user.

writerは、ユーザによりオープンされている必要があります。


FileAppender

public FileAppender(Layout layout,
                    String filename,
                    boolean append)
             throws IOException
Instantiate a FileAppender and open the file designated by filename. The opened filename will become the output destination for this appender.

FileAppenderのインスタンスを生成し、filenameで指定されたファイルをオープンします。 そのオープンされたファイルがこのアペンダの出力先になります。

If the append parameter is true, the file will be appended to. Otherwise, the file designated by filename will be truncated before being opened.

もし、appendパラメタがtrueの場合、ファイルに追加されます。 そうでない場合、filename用に設計されたファイルがオープンされる前に追加されなくなります。


FileAppender

public FileAppender(Layout layout,
                    String filename)
             throws IOException
Instantiate a FileAppender and open the file designated by filename. The opened filename will become the output destination for this appender.

FileAppenderのインスタンスを生成し、filenameに指定されたファイルをオープンします。 そのオープンされたファイル名は、このアペンダの出力先となります。

The file will be appended to.

そのファイルに対し追加されます。

メソッドの詳細

setFile

public void setFile(String file)
The File option takes a string value which should be the name of the file to append to. Special values "System.out" or "System.err" are interpreted as the standard out and standard error streams.

Fileオプションは、追加する対象のファイルの名であるはずの文字列の値を取ります。 特別な値、"System.out" または "System.err" は、標準出力と標準エラーとして解釈されます。

Note that the "System.out" or "System.err" options are deprecated. Use ConsoleAppender instead.

"System.out" または "System.err" オプションは、推奨されていないことに気を付けてください。代替として、ConsoleAppenderを使ってください。

If the option is set to "System.out" or "System.err" the output will go to the corresponding stream. Otherwise, if the option is set to the name of a file, then the file will be opened and output will go there.

もし、オプションに "System.out" または "System.err" が設定されている場合、出力は、一致するストリームに対して行われます。 そうでない場合は、もしオプションにファイル名が設定されている場合、その時は、そのファイルがオープンされ、そこに出力されます。

Note: Actual opening of the file is made when activateOptions() is called, not when the options are set.

注意: 実際にファイルのオープンは、オプションが設定される時ではなく、activateOptions()が呼び出されるときに作成されます。


getAppend

public boolean getAppend()
Returns the value of the Append option.

Appendオプションの値を返します。


getFile

public String getFile()
Returns the value of the File option.

Fileオプションの値を返します。


getOptionStrings

public String[] getOptionStrings()
推奨されていません。 We now use JavaBeans introspection to configure components. Options strings are no longer needed.

今日、私たちは、コンポーネントの設定には、JavaBeansのイントロスペクションを利用します。 オプション文字列は、今後必要なくなります。

Returns the option names for this component, namely the string array FILE_OPTION, APPEND_OPTION} in addition to the options of its super class WriterAppender.

このコンポーネントのオプション名を返します。 名前としては、文字列配列の FILE_OPTION と親クラスWriterAppenderのオプションに追加する際のAPPEND_OPTIONがあります。

オーバーライド:
クラス WriterAppender 内の getOptionStrings

setAppend

public void setAppend(boolean flag)
The Append option takes a boolean value. It is set to true by default. If true, then File will be opened in append mode by setFile (see above). Otherwise, setFile will open File in truncate mode.

Appendオプションは、論理値をとります。 デフォルトでは、trueに設定されます。 もし、true の場合、その時は、FilesetFile(上記を参照してください)による追加モードでオープンされます。 そうでない場合、setFile は、追加しないモードでFileをオープンします。

Note: Actual opening of the file is made when activateOptions() is called, not when the options are set.

注意: ファイルの実際のオープンは、オプションが設定される時ではなく、activateOptions()が呼び出される時に作成されます。


activateOptions

public void activateOptions()
If the value of FILE_OPTION is not null, then setFile(java.lang.String) is called with the values of FILE_OPTION and APPEND_OPTION.

もし、FILE_OPTIONの値が、nullでない場合、その時、setFile(java.lang.String) は、FILE_OPTIONAPPEND_OPTION を使って値が呼び出されます。

オーバーライド:
クラス WriterAppender 内の activateOptions
導入されたバージョン:
0.8.1

closeFile

protected void closeFile()
Closes the previously opened file.

先にオープンしたファイルをクローズします。


setFile

public void setFile(String fileName,
                    boolean append)
             throws IOException

Sets and opens the file where the log output will go. The specified file must be writable.

ログ出力を行うファイルを設定し、オープンします。 指定したファイルは、書き込み可能である必要があります。

If there was already an opened file, then the previous file is closed first.

もし、すでにオープンされたファイルがあれば、先にオープンされたファイルが最初にクローズされます。

パラメータ:
fileName - The path to the log file.

fileName ログファイルへのパス

append - If true will append to fileName. Otherwise will truncate fileName.

append trueの場合は、ファイルへ追加されます。 そうでない場合は、fileNameへは、追加されません。


setOption

public void setOption(String key,
                      String value)
推奨されていません。 Use the setter method for the option directly instead of the generic setOption method.

汎用的なsetOptionメソッドの代わりに、直接オプションを扱うセッタメソッドを利用します。

インタフェース OptionHandler の記述:
Set option to value.

オプション に設定します。

The handling of each option depends on the OptionHandler instance. Some options may become active immediately whereas other may be activated only when OptionHandler.activateOptions() is called.

各オプションの処理は、OptionHandlerのインスタンスに依存します。 いくつかのオプションは、直ぐに有効になりますが、その他は OptionHandler.activateOptions()が呼ばれる時にだけ有効になります。

オーバーライド:
クラス WriterAppender 内の setOption

setQWForFiles

protected void setQWForFiles(Writer writer)
Sets the quiet writer being used.

利用されるquietライタを設定します。

This method is overriden by RollingFileAppender.

このメソッドは、RollingFileAppenderにオーバーライドされます。


reset

protected void reset()
Close any previously opened file and call the parent's reset.

先にオープンしているファイルをクローズし、親のresetを呼び出します。

オーバーライド:
クラス WriterAppender 内の reset


Please notify me about new log4j releases.