com.taobao.metamorphosis.client.extension.log4j
类 StreamAppender

java.lang.Object
  继承者 org.apache.log4j.AppenderSkeleton
      继承者 com.taobao.metamorphosis.client.extension.log4j.StreamAppender
所有已实现的接口:
org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler
直接已知子类:
FileStreamAppender

public class StreamAppender
extends org.apache.log4j.AppenderSkeleton

从以下版本开始:
1.0, 2009-10-20 下午03:29:12
作者:
wuxin,, boyan

字段摘要
protected  int connectionPool
          Connection pool size for producer
protected  CodecBuilder.Codec_Type encodeType
          The encodeType variable is set to Codec_Type.HESSIAN by default.
protected  boolean immediateFlush
          Immediate flush means that the underlying writer or output stream will be flushed at the end of each append operation.
protected  AsyncMessageSessionFactory messageSessionFactory
           
protected  OutputStream out
          This is the quietWriter where we will write to.
protected  AsyncMessageProducer producer
           
protected  String topic
          Default topic is the same with name
protected  ZkUtils.ZKConfig zkConfig
           
 
从类 org.apache.log4j.AppenderSkeleton 继承的字段
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
 
构造方法摘要
StreamAppender()
          This default constructor does nothing.
StreamAppender(org.apache.log4j.Layout layout, OutputStream writer)
          Instantiate a WriterAppender and set the output destination to writer.
 
方法摘要
 void activateOptions()
          Does nothing.
 void append(org.apache.log4j.spi.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.
 int getEncodeType()
           
 boolean getImmediateFlush()
          Returns value of the ImmediateFlush option.
 String getTopic()
           
 boolean requiresLayout()
          The WriterAppender requires a layout.
protected  void reset()
          Clear internal references to the writer and other variables.
 void setEncodeType(int encodeType)
           
 void setImmediateFlush(boolean value)
          If the ImmediateFlush option is set to true, the appender will flush at the end of each write.
 void setName(String name)
          Set the name of this Appender.
 void setTopic(String topic)
           
 void setZkConnect(String zkConnect)
           
protected  void subAppend(org.apache.log4j.spi.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, setErrorHandler, setLayout, setThreshold
 
从类 java.lang.Object 继承的方法
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

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.

The immediateFlush variable is set to true by default.


out

protected OutputStream out
This is the quietWriter where we will write to.


topic

protected String topic
Default topic is the same with name


encodeType

protected CodecBuilder.Codec_Type encodeType
The encodeType variable is set to Codec_Type.HESSIAN by default.


connectionPool

protected int connectionPool
Connection pool size for producer


messageSessionFactory

protected AsyncMessageSessionFactory messageSessionFactory

producer

protected AsyncMessageProducer producer

zkConfig

protected ZkUtils.ZKConfig zkConfig
构造方法详细信息

StreamAppender

public StreamAppender()
This default constructor does nothing.


StreamAppender

public StreamAppender(org.apache.log4j.Layout layout,
                      OutputStream writer)
Instantiate a WriterAppender and set the output destination to writer.

The writer must have been previously opened by the user.

方法详细信息

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.

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.


getImmediateFlush

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


getTopic

public String getTopic()

setTopic

public void setTopic(String topic)

setZkConnect

public void setZkConnect(String zkConnect)

getEncodeType

public int getEncodeType()

setEncodeType

public void setEncodeType(int encodeType)

setName

public void setName(String name)
Set the name of this Appender.

指定者:
接口 org.apache.log4j.Appender 中的 setName
覆盖:
org.apache.log4j.AppenderSkeleton 中的 setName

activateOptions

public void activateOptions()
Does nothing.

指定者:
接口 org.apache.log4j.spi.OptionHandler 中的 activateOptions
覆盖:
org.apache.log4j.AppenderSkeleton 中的 activateOptions

append

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

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.

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

指定者:
org.apache.log4j.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.


subAppend

protected void subAppend(org.apache.log4j.spi.LoggingEvent event)
Actual writing occurs here.

Most subclasses of WriterAppender will need to override this method.

从以下版本开始:
0.9.0

close

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

Closed appenders cannot be reused.

指定者:
接口 org.apache.log4j.Appender 中的 close
指定者:
org.apache.log4j.AppenderSkeleton 中的 close
从以下版本开始:
0.8.4
另请参见:
#setWriter

closeWriter

protected void closeWriter()
Close the underlying Writer.


requiresLayout

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

指定者:
接口 org.apache.log4j.Appender 中的 requiresLayout
指定者:
org.apache.log4j.AppenderSkeleton 中的 requiresLayout

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.


writeHeader

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



Copyright © 2010–2013. All rights reserved.