org.apache.log4j
クラス AsyncAppender

java.lang.Object
  |
  +--org.apache.log4j.AppenderSkeleton
        |
        +--org.apache.log4j.AsyncAppender
すべての実装インタフェース:
Appender, AppenderAttachable, OptionHandler

public class AsyncAppender
extends AppenderSkeleton
implements AppenderAttachable

The AsyncAppender lets users log events asynchronously. It uses a bounded buffer to store logging events.

AsyncAppenderによりユーザは、非同期でイベントを記録することができます。 ロギングイベントを貯えるために有限バッファを使います。

The AsyncAppender will collect the events sent to it and then dispatch them to all the appenders that are attached to it. You can attach multiple appenders to an AsyncAppender.

AsyncAppenderは、自分に対し送られてきたイベントを集め、それから自分にアタッチされた全てのアペンダへイベントを配信します。

The AsyncAppender uses a separate thread to serve the events in its bounded buffer.

AsyncAppenderはその有限バッファ内のイベントを送出するために分離したスレッドを利用します。

Refer to the results in Logging for the impact of using this appender.

このアペンダを使うことでの影響に関しては、Loggingでの結果を参照してください。

Important note: The AsyncAppender can only be script configured using the DOMConfigurator. Refer to example configuration files sample4.xml and sample5.xml.

重要事項:AsyncAppenderは、DOMConfiguratorを使うために設定される単純なスクリプトです。 sample4.xml and sample5.xmlの設定ファイルの例を参照してください。

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

フィールドの概要
static String BUFFER_SIZE_OPTION
          推奨されていません。 Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.

オプションは、現状、JavaBeanパラダイムを使うことで処理されます。 この定数は、今後必要なくなり、近いうちに削除される予定です。

static int DEFAULT_BUFFER_SIZE
          The default buffer size is set to 128 events.
static String LOCATION_INFO_OPTION
          推奨されていません。 Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.

オプションは、現状、JavaBeanパラダイムを使うことで処理されます。 この定数は、今後必要なくなり、近いうちに削除される予定です。

 
クラス org.apache.log4j.AppenderSkeleton から継承したフィールド
closed, errorHandler, headFilter, layout, name, tailFilter, threshold, THRESHOLD_OPTION
 
コンストラクタの概要
AsyncAppender()
           
 
メソッドの概要
 void addAppender(Appender newAppender)
          Add an appender.
 void append(LoggingEvent event)
          Subclasses of AppenderSkeleton should implement this method to perform actual logging.
 void close()
          Close this AsyncAppender by interrupting the dispatcher thread which will process all pending events before exiting.
 Enumeration getAllAppenders()
          Get all previously added appenders as an Enumeration.
 Appender getAppender(String name)
          Get an appender by name.
 int getBufferSize()
          Returns the current value of the BufferSize option.
 boolean getLocationInfo()
          Returns the current value of the LocationInfo option.
 String[] getOptionStrings()
          推奨されていません。 We now use JavaBeans introspection to configure components. Options strings are no longer needed.

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

 void removeAllAppenders()
          Remove all previously added appenders.
 void removeAppender(Appender appender)
          Remove the appender passed as parameter from the list of appenders.
 void removeAppender(String name)
          Remove the appender with the name passed as parameter from the list of appenders.
 boolean requiresLayout()
          The AsyncAppender does not require a layout.
 void setBufferSize(int size)
          The BufferSize option takes a non-negative integer value.
 void setLocationInfo(boolean flag)
          The LocationInfo option takes a boolean value.
 void setOption(String option, String value)
          推奨されていません。 Use the setter method for the option directly instead of the generic setOption method.

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

 
クラス org.apache.log4j.AppenderSkeleton から継承したメソッド
activateOptions, addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
 
クラス java.lang.Object から継承したメソッド
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

LOCATION_INFO_OPTION

public static final String LOCATION_INFO_OPTION
推奨されていません。 Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.

オプションは、現状、JavaBeanパラダイムを使うことで処理されます。 この定数は、今後必要なくなり、近いうちに削除される予定です。

A string constant used in naming the option for setting the location information flag. Current value of this string constant is LocationInfo.

ロケーション情報フラグを設定するためのオプションに名前を付ける際に利用される文字列定数です。 文字列定数の現状の値は、LocationInfoです。

Note that all option keys are case sensitive.

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


BUFFER_SIZE_OPTION

public static final String BUFFER_SIZE_OPTION
推奨されていません。 Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term.

オプションは、現状、JavaBeanパラダイムを使うことで処理されます。 この定数は、今後必要なくなり、近いうちに削除される予定です。

A string constant used in naming the option for setting the size of the internal buffer where logging events are stored until they are written. Current value of this string constant is BufferSize.

ロギングイベントが書き込まれるまで保存される内部バッファのサイズを設定するためのオプションに名前を付ける際に利用される文字列定数です。

Note that all option keys are case sensitive.

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


DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
The default buffer size is set to 128 events.

デフォルトバッファのサイズは、128イベントに設定されます。

コンストラクタの詳細

AsyncAppender

public AsyncAppender()
メソッドの詳細

addAppender

public void addAppender(Appender newAppender)
インタフェース AppenderAttachable の記述:
Add an appender.

アペンダを追加します。

定義:
インタフェース AppenderAttachable 内の addAppender

append

public void append(LoggingEvent event)
クラス AppenderSkeleton の記述:
Subclasses of AppenderSkeleton should implement this method to perform actual logging. See also AppenderSkeleton.doAppend method.

AppenderSkeletonのサブクラスは実際にロギングを行うためにこのメソッドを実装する必要があります。 AppenderSkeleton.doAppendメソッドを参照してください。

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

close

public void close()
Close this AsyncAppender by interrupting the dispatcher thread which will process all pending events before exiting.

処理を抜ける前にすべての未送出イベントを処理する送出スレッドに割り込むことで、このAsyncAppenderをクローズします。


getAllAppenders

public Enumeration getAllAppenders()
インタフェース AppenderAttachable の記述:
Get all previously added appenders as an Enumeration.

前もって追加してあった全てのアペンダを列挙(Enumeration)として取り出します。

定義:
インタフェース AppenderAttachable 内の getAllAppenders

getAppender

public Appender getAppender(String name)
インタフェース AppenderAttachable の記述:
Get an appender by name.

名前を使ってアペンダを取り出します。

定義:
インタフェース AppenderAttachable 内の getAppender

getLocationInfo

public boolean getLocationInfo()
Returns the current value of the LocationInfo option.

LocationInfoオプションの現在の値を返します。


requiresLayout

public boolean requiresLayout()
The AsyncAppender does not require a layout. Hence, this method always returns false.

AsyncAppenderはレイアウトを要求しません。従って、このメソッドは必ずfalseを返します。


removeAllAppenders

public void removeAllAppenders()
インタフェース AppenderAttachable の記述:
Remove all previously added appenders.

前もって追加してあった全てのアペンダを削除します。

定義:
インタフェース AppenderAttachable 内の removeAllAppenders

removeAppender

public void removeAppender(Appender appender)
インタフェース AppenderAttachable の記述:
Remove the appender passed as parameter from the list of appenders.

パラメタで渡されたアペンダをアペンダのリストから削除します。

定義:
インタフェース AppenderAttachable 内の removeAppender

removeAppender

public void removeAppender(String name)
インタフェース AppenderAttachable の記述:
Remove the appender with the name passed as parameter from the list of appenders.

パラメタで渡された名前を使ってアペンダのリストから削除します。

定義:
インタフェース AppenderAttachable 内の removeAppender

setLocationInfo

public void setLocationInfo(boolean flag)
The LocationInfo option takes a boolean value. By default, it is set to false which means there will be no effort to extract the location information related to the event. As a result, the event that will be ultimately logged will likely to contain the wrong location information (if present in the log format).

LocationInfoオプションは、論理値を取ります。 デフォルトで、falseに設定され、それは、イベントに関連する位置情報を取り出さないことを意味します。 結果として、最終的にログ出力されるイベントは、(仮に、ログフォーマットに記述があれば)間違った位置情報を含む可能性があります。

Location information extraction is comparatively very slow and should be avoided unless performance is not a concern.

位置情報の抽出は比較しようもないほど遅いし、パフォーマンスが気になるのであれば、使用は避けるべきでしょう。


setBufferSize

public void setBufferSize(int size)
The BufferSize option takes a non-negative integer value. This integer value determines the maximum size of the bounded buffer. Increasing the size of the buffer is always safe. However, if an existing buffer holds unwritten elements, then decreasing the buffer size will result in event loss. Nevertheless, while script configuring the AsyncAppender, it is safe to set a buffer size smaller than the default buffer size because configurators guarantee that an appender cannot be used before being completely configured.

BufferSizeオプションは、非負整数を取ります。 この整数値は有限バッファの最大値を決定します。 バッファのサイズを増やしていくことで必ず安全性が保たれます。 しかし、万が一存在するバッファが記録されていない要素を持ったままの状態になった場合、バッファのサイズを小さくしてしまうとイベントロスという結果になります。 それでも、スクリプトがAsyncAppenderを設定している間、default buffer sizeより小さいバッファサイズを設定しても安全です。 というのも、コンフィギュレータは、アペンダが完全に設定される前に利用できないことを保証しています。


getBufferSize

public int getBufferSize()
Returns the current value of the BufferSize option.

BufferSizeオプションの現在の値を返します。


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 in addition in addition to the options of its super class AppenderSkeleton.

スーパークラスAppenderSkeletonのオプションに加え、このコンポーネントに関するオプション名を返します。

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

setOption

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

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

Set AsyncAppender specific options:

AsyncAppenderの具体的なオプションの設定:

On top of the options of the super class AppenderSkeleton, the only recognized options are BufferSize and LocationInfo.

スーパークラス AppenderSkeletonのオプションの上位で、唯一認識されるオプションは、BufferSizeLocationInfoです。

The BufferSize option takes a non-negative integer value. This integer value determines the maximum size of the bounded buffer. Increasing the size of the buffer is always safe. However, if an existing buffer holds unwritten elements, then decreasing the buffer size will result in event loss. Nevertheless, while script configuring the AsyncAppender, it is safe to set a buffer size smaller than the default buffer size because configurators guarantee that an appender cannot be used before being completely configured.

BufferSizeオプションは、非負整数値をとります。 この整数値は、有限バッファの最大サイズを決定します。 バッファサイズを増やすことで必ず安全になります。しかし、既存のバッファが記録されない要素を持っている場合、バッファサイズを減らすことでイベントのロスに繋がります。 それでも、スクリプトがAsyncAppenderを設定している間、default buffer sizeより小さいバッファサイズを設定しても安全です。 というのは、コンフィギュレータは、完全に設定されないとアペンダは利用できないことを保証しているからです。

The LocationInfo option takes a boolean value. By default, it is set to false which means there will be no effort to extract the location information related to the event. As a result, the event that will be ultimately logged will likely to contain the wrong location information (if present in the log format). LocationInfoオプションは、論理値を取ります。 デフォルトで、falseに設定され、それは、イベントに関連する位置情報を取り出さないことを意味します。 結果として、最終的にログ出力されるイベントは、(仮に、ログフォーマットに記述があれば)間違った位置情報を含む可能性があります。

Location information extraction is comparatively very slow and should be avoided unless performance is not a concern.

位置情報の抽出は比較しようもないほど遅いし、パフォーマンスが気になるのであれば、使用は避けるべきでしょう。

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


Please notify me about new log4j releases.