com.funambol.util
Class FileAppender

java.lang.Object
  extended by com.funambol.util.FileAppender
All Implemented Interfaces:
Appender

public class FileAppender
extends java.lang.Object
implements Appender

This appender logs messages to a file using JSR75 (FileConnection) The appender tracks the file size and if it exceeds a given maximum size (customizable by clients) then the current log file is renamed appending a .old to the log name and a new one is created. Therefore the maximum size on this is about 2 times the maxFileSize (this is not accurate as there is no limit on the size of the single message printed).


Constructor Summary
FileAppender(java.lang.String path, java.lang.String fileName)
          Default constructor
 
Method Summary
 void closeLogFile()
          Close connection and streams
 void deleteLogFile()
          Delete the log file
 void initLogFile()
          Init the logger
 void openLogFile()
          FileAppender doesn't implement this method
 void setMaxFileSize(long maxFileSize)
          Sets the maximum file size.
 void writeLogMessage(java.lang.String level, java.lang.String msg)
          FileAppender writes one message to the output file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileAppender

public FileAppender(java.lang.String path,
                    java.lang.String fileName)
Default constructor

Method Detail

setMaxFileSize

public void setMaxFileSize(long maxFileSize)
Sets the maximum file size. Once this is size is reached, the current log file is renamed and a new one is created. This way we have at most 2 log files whose size is (roughly) bound to maxFileSize. The minimum file size is 1024 as smaller size does not really make sense. If a client needs smaller files it should probably the usage of other Appenders or modify the behavior of this one by deriving it.


writeLogMessage

public void writeLogMessage(java.lang.String level,
                            java.lang.String msg)
FileAppender writes one message to the output file

Specified by:
writeLogMessage in interface Appender

initLogFile

public void initLogFile()
Init the logger

Specified by:
initLogFile in interface Appender

openLogFile

public void openLogFile()
FileAppender doesn't implement this method

Specified by:
openLogFile in interface Appender

closeLogFile

public void closeLogFile()
Close connection and streams

Specified by:
closeLogFile in interface Appender

deleteLogFile

public void deleteLogFile()
Delete the log file

Specified by:
deleteLogFile in interface Appender


Copyright © 2006 Funambol.