org.apache.log4j
クラス WriterAppender

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

public class WriterAppender
extends AppenderSkeleton

WriterAppender appends log events to a Writer or an OutputStream depending on the user's choice.

WriterAppender は、ユーザの選択により、Writer または OutputStream にログイベントを追加します。

導入されたバージョン:
1.1
作成者:
Ceki Gülcü

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

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

protected  boolean immediateFlush
          Immediate flush means that the underlying writer or output stream will be flushed at the end of each append operation.
protected  QuietWriter qw
          This is the quietWriter where we will write to.
 
クラス org.apache.log4j.AppenderSkeleton から継承したフィールド
closed, errorHandler, headFilter, layout, name, tailFilter, threshold, THRESHOLD_OPTION
 
コンストラクタの概要
WriterAppender()
          This default constructor does nothing.
WriterAppender(Layout layout, OutputStream os)
          Instantiate a WriterAppender and set the output destination to a new OutputStreamWriter initialized with os as its OutputStream.
WriterAppender(Layout layout, Writer writer)
          Instantiate a WriterAppender and set the output destination to writer.
 
メソッドの概要
 void activateOptions()
          Does nothing.
 void append(LoggingEvent event)
          This method is called by the AppenderSkeleton.doAppend(org.apache.log4j.spi.LoggingEvent) method.
protected  boolean checkEntryConditions()
          This method determines if there is a sense in attempting to append.
 void close()
          Close this appender instance.
protected  void closeWriter()
          Close the underlying Writer.
 boolean getImmediateFlush()
          Returns value of the ImmediateFlush option.
 String[] getOptionStrings()
          推奨されていません。 We now use JavaBeans introspection to configure components. Options strings are no longer needed.

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

 boolean requiresLayout()
          The WriterAppender requires a layout.
protected  void reset()
          Clear internal references to the writer and other variables.
 void setErrorHandler(ErrorHandler eh)
          Set the ErrorHandler for this FileAppender and also the underlying QuietWriter if any.
 void setImmediateFlush(boolean value)
          If the ImmediateFlush option is set to true, the appender will flush at the end of each write.
 void setOption(String key, String value)
          Set option to value.
 void setWriter(Writer writer)
          Sets the Writer where the log output will go.
protected  void subAppend(LoggingEvent event)
          Actual writing occurs here.
protected  void writeFooter()
          Write a footer as produced by the embedded layout's Layout.getFooter() method.
protected  void writeHeader()
          Write a header as produced by the embedded layout's Layout.getHeader() method.
 
クラス 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
 

フィールドの詳細

IMMEDIATE_FLUSH_OPTION

public static final String IMMEDIATE_FLUSH_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 immediate flushing of the output stream at the end of each append operation. Current value of this string constant is ImmediateFlush.

各追加オペレーションの最後で、出力ストリームをすぐにフラッシュしたい場合のオプションに指定する時に使う文字列定数です。

Note that all option keys are case sensitive.

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


immediateFlush

protected boolean immediateFlush
Immediate flush means that the underlying writer or output stream will be flushed at the end of each append operation. Immediate flush is slower but ensures that each append request is actually written. If immediateFlush is set to false, then there is a good chance that the last few logs events are not actually written to persistent media if and when the application crashes.

早急のフラッシュとは、生成されたライターまたは出力ストリームが各対かオペレーションの最後でフラッシュするということを意味しています。 早急なフラッシュは、遅いですが、各追加要求が実際に書き出されたことを保証します。 immediateFlushfalseに設定されている場合、アプリケーションがクラッシュした時、最後の残りのログイベントが実際には、永続性を保つメディアへの書き込みがされないというよい面があります。

The immediateFlush variable is set to true by default.

デフォルトでは、immediateFlush変数は、trueに設定されています。


qw

protected QuietWriter qw
This is the quietWriter where we will write to.

これは、私たちが書き込む quietWriter です。

コンストラクタの詳細

WriterAppender

public WriterAppender()
This default constructor does nothing.

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


WriterAppender

public WriterAppender(Layout layout,
                      OutputStream os)
Instantiate a WriterAppender and set the output destination to a new OutputStreamWriter initialized with os as its OutputStream.

WriterAppender をインスタンス化し、OutputStream としての os を使って新しく初期化される OutputStream を出力先として設定します。


WriterAppender

public WriterAppender(Layout layout,
                      Writer writer)
Instantiate a WriterAppender and set the output destination to writer.

WriterAppenderをインスタンス化し、writer を出力先として設定します。

The writer must have been previously opened by the user.

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

メソッドの詳細

setImmediateFlush

public void setImmediateFlush(boolean value)
If the ImmediateFlush option is set to true, the appender will flush at the end of each write. This is the default behavior. If the option is set to false, then the underlying stream can defer writing to physical medium to a later time.

もし、immediateFlush オプションが true に設定されている場合、アペンダは、各書き込みの最後でフラッシュします。 もし、オプションが false に設定されている場合、その時は、生成されたストリームは、物理的なメディアへの書き込みを後にのばします。

Avoiding the flush operation at the end of each append results in a performance gain of 10 to 20 percent. However, there is safety tradeoff involved in skipping flushing. Indeed, when flushing is skipped, then it is likely that the last few log events will not be recorded on disk when the application exits. This is a high price to pay even for a 20% performance gain.

各追加の最後でフラッシュ処理をしないことで、10から20パーセントパフォーマンスが上昇するという結果をもたらします。 しかし、安全なトレードオフは、フラッシングをスキップすることでおこります。 実際、フラッシュがスキップされると、アプリケーションが生きている時でも、最後の残りのログイベントがディスクに記録されないということがありえます。 これは、20%のパフォーマンス上昇と引換に払う高い代償ともいえます。


getImmediateFlush

public boolean getImmediateFlush()
Returns value of the ImmediateFlush option.

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


activateOptions

public void activateOptions()
Does nothing.

何もしません。

オーバーライド:
クラス AppenderSkeleton 内の activateOptions

append

public void append(LoggingEvent event)
This method is called by the AppenderSkeleton.doAppend(org.apache.log4j.spi.LoggingEvent) method.

このメソッドは、AppenderSkeleton.doAppend(org.apache.log4j.spi.LoggingEvent) メソッドにより呼ばれます。

If the output stream exists and is writable then write a log statement to the output stream. Otherwise, write a single warning message to System.err.

もし、出力ストリームが存在し、書き込みが可能であれば、出力ストリームにログステートメントを書き込みます。 そうでなければ、System.err に単独の警告メッセージを書き込みます。

The format of the output will depend on this appender's layout.

出力のフォーマットは、このアペンダのレイアウトにしたがいます。

オーバーライド:
クラス AppenderSkeleton 内の append

checkEntryConditions

protected boolean checkEntryConditions()
This method determines if there is a sense in attempting to append.

It checks whether there is a set output target and also if there is a set layout. If these checks fail, then the boolean value false is returned.

セットした出力のターゲットが存在するか、また、セットしたレイアウトが存在するかをチェックします。 もしこれらのチェックが失敗した場合、論理値 false が返されます。


close

public void close()
Close this appender instance. The underlying stream or writer is also closed.

このアペンダのインスタンスをクローズします。 生成されているストリームまたはライタもクローズします。

Closed appenders cannot be reused.

クローズされたアペンダは、再利用できません。

導入されたバージョン:
0.8.4
関連項目:
setWriter(java.io.Writer)

closeWriter

protected void closeWriter()
Close the underlying Writer.

生成された、Writer をクローズします。


getOptionStrings

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

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

Retuns the option names for this component.

このコンポーネントのオプション名を返します。

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

setErrorHandler

public void setErrorHandler(ErrorHandler eh)
Set the ErrorHandler for this FileAppender and also the underlying QuietWriter if any.

FileAppenderが要求する ErrorHandler と あれば 生成された QuietWriter を設定します。

オーバーライド:
クラス AppenderSkeleton 内の setErrorHandler

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()が呼ばれる時にだけ有効になります。

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

setWriter

public void setWriter(Writer writer)

Sets the Writer where the log output will go. The specified Writer must be opened by the user and be writable.

ログの出力が行われる場合のライタを設定します。 その指定されたライタは、ユーザによりオープンされている必要があり、書き込み可能でなくては、なりません。

The java.io.Writer will be closed when the appender instance is closed.

java.io.Writer は、アペンダのインスタンスがクローズした時にクローズされます。

WARNING: Logging to an unopened Writer will fail.

注意: オープンされていないライタへのロギング処理は、失敗するでしょう。

パラメータ:
Writer - An already opened Writer.

Writer すでにオープンされたライタ


subAppend

protected void subAppend(LoggingEvent event)
Actual writing occurs here.

実際の書き込みは、ここで行われます。

Most subclasses of WriterAppender will need to override this method.

ほとんどの WriterAppender のサブクラスは、このメソッドをオーバーライドする必要があります。

導入されたバージョン:
0.9.0

requiresLayout

public boolean requiresLayout()
The WriterAppender requires a layout. Hence, this method returns true.

WriterAppender は、レイアウトを要求します。 従って、このメソッドは、true を返します。


reset

protected void reset()
Clear internal references to the writer and other variables.

ライタと他の変数たちへの内部参照をクリアします。

Subclasses can override this method for an alternate closing behavior.

サブクラスは、相互のクローズの振る舞いを行うために、このメソッドをオーバーライドします。


writeFooter

protected void writeFooter()
Write a footer as produced by the embedded layout's Layout.getFooter() method.

組み込まれたレイアウトの Layout.getHeader() メソッドにより作成されるようなフッタを書き込みます。


writeHeader

protected void writeHeader()
Write a header as produced by the embedded layout's Layout.getHeader() method.

組み込まれたレイアウトの Layout.getHeader() メソッドにより作成されるようなヘッダを書き込みます。



Please notify me about new log4j releases.