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

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

public class FileStreamAppender
extends StreamAppender

从以下版本开始:
1.0, 2009-10-20 下午03:49:32
作者:
wuxin

字段摘要
protected  boolean bufferedIO
          Do we do bufferedIO?
protected  int bufferSize
          Determines the size of IO buffer be.
protected  boolean fileAppend
          Controls file truncatation.
protected  String fileName
          The name of the log file.
 
从类 com.taobao.metamorphosis.client.extension.log4j.StreamAppender 继承的字段
connectionPool, encodeType, immediateFlush, messageSessionFactory, out, producer, topic, zkConfig
 
从类 org.apache.log4j.AppenderSkeleton 继承的字段
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
 
构造方法摘要
FileStreamAppender()
          The default constructor does not do anything.
FileStreamAppender(org.apache.log4j.Layout layout, String filename)
          Instantiate a FileAppender and open the file designated by filename.
FileStreamAppender(org.apache.log4j.Layout layout, String filename, boolean append)
          Instantiate a FileAppender and open the file designated by filename.
FileStreamAppender(org.apache.log4j.Layout layout, String filename, boolean append, boolean bufferedIO, int bufferSize)
          Instantiate a FileAppender and open the file designated by filename.
 
方法摘要
 void activateOptions()
          If the value of File is not null, then setFile(java.lang.String) is called with the values of File and Append properties.
protected  void closeFile()
          Closes the previously opened file.
 boolean getAppend()
          Returns the value of the Append option.
 boolean getBufferedIO()
          Get the value of the BufferedIO option.
 int getBufferSize()
          Get the size of the IO buffer.
 String getFile()
          Returns the value of the File option.
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 setBufferedIO(boolean bufferedIO)
          The BufferedIO option takes a boolean value.
 void setBufferSize(int bufferSize)
          Set the size of the IO buffer.
 void setFile(String file)
          The File property takes a string value which should be the name of the file to append to.
 void setFile(String fileName, boolean append, boolean bufferedIO, int bufferSize)
           Sets and opens the file where the log output will go.
 
从类 com.taobao.metamorphosis.client.extension.log4j.StreamAppender 继承的方法
append, checkEntryConditions, close, closeWriter, getEncodeType, getImmediateFlush, getTopic, requiresLayout, setEncodeType, setImmediateFlush, setName, setTopic, setZkConnect, subAppend, writeFooter, writeHeader
 
从类 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
 

字段详细信息

fileAppend

protected boolean fileAppend
Controls file truncatation. 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.


fileName

protected String fileName
The name of the log file.


bufferedIO

protected boolean bufferedIO
Do we do bufferedIO?


bufferSize

protected int bufferSize
Determines the size of IO buffer be. Default is 8K.

构造方法详细信息

FileStreamAppender

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


FileStreamAppender

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

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

If the bufferedIO parameter is true, then buffered IO will be used to write to the output file.

抛出:
IOException

FileStreamAppender

public FileStreamAppender(org.apache.log4j.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.

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

抛出:
IOException

FileStreamAppender

public FileStreamAppender(org.apache.log4j.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.

The file will be appended to.

抛出:
IOException
方法详细信息

setFile

public void setFile(String file)
The File property takes a string value which should be the name of the file to append to.

Note that the special values "System.out" or "System.err" are no longer honored.

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


getAppend

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


getFile

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


activateOptions

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

指定者:
接口 org.apache.log4j.spi.OptionHandler 中的 activateOptions
覆盖:
StreamAppender 中的 activateOptions
从以下版本开始:
0.8.1

closeFile

protected void closeFile()
Closes the previously opened file.


getBufferedIO

public boolean getBufferedIO()
Get the value of the BufferedIO option.

BufferedIO will significatnly increase performance on heavily loaded systems.


getBufferSize

public int getBufferSize()
Get the size of the IO buffer.


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.

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


setBufferedIO

public void setBufferedIO(boolean bufferedIO)
The BufferedIO option takes a boolean value. It is set to false by default. If true, then File will be opened and the resulting Writer wrapped around a BufferedWriter. BufferedIO will significatnly increase performance on heavily loaded systems.


setBufferSize

public void setBufferSize(int bufferSize)
Set the size of the IO buffer.


setFile

public void setFile(String fileName,
                    boolean append,
                    boolean bufferedIO,
                    int bufferSize)
             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.

Do not use this method directly. To configure a FileAppender or one of its subclasses, set its properties one by one and then call activateOptions.

参数:
fileName - The path to the log file.
append - If true will append to fileName. Otherwise will truncate fileName.
抛出:
IOException

reset

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

覆盖:
StreamAppender 中的 reset


Copyright © 2010–2013. All rights reserved.