|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.adventnet.afp.log.AbstractLogWriter | +--com.adventnet.afp.log.FileLogWriter
FilelogWriter is a default implementation of the LogWriter provided
by the Logging Framework. As the name implies, the FilelogWriter
redirects all the log out and log error messages to the corresponding files.
When the number of lines in the file in
current use reaches the maximum number specified in the configuration,
the FilelogWriter automatically opens a new file and all further log messages
will be written into it and so on.
By default, the FilelogWriter prescribes names for the file in current use and for all further files. The file in current use will be named always as serverout.txt or servererr.txt. The name for the previous files, will be in incremented order. For example, supposing the FilelogWriter has created 5 files and the 6th one is the current file, then, the fifth file will bear the name serverout1.txt, the fourth file will have the name serverout2.txt and so on.
All the new files will have the label "LOG_STARTED_STR" on their top. If a new file is the continuation of the previous one, it will bear the label "LOG_CONTINUED_STR" on its top.
Whenever the number of files reaches the maximum prescribed limit in
the configuration , the oldest file (in other words, the first generated
file) is moved to the Archives. For example, the default value for the
parameter MaxFileCount is set as 10. Upon
reaching this maximum count, when the 11th file is created, the first
one is moved to the Archives. When there arises a need to refer to the
first file, you may visit the Archives and pick that file.
Buffering can be done in two modes - Auto or Manual. The custom properties
are file name, maximum line count, maximum
file count , Buffer size,Flush mode, Logs directory, Archive directory
and; Archive status. The key names for all the Custom properties
are FileName,MaxLineCount,MaxFileCount,BufferSize,FlushMode, LogsDirectory,ArchiveDirectory
and ArchiveStatus. The user can give their own property under the Property
tag similar to the properties mentioned above.(FileName,MaxLineCount
etc) which are considered to be as custom properties.
Fields inherited from class com.adventnet.afp.log.AbstractLogWriter |
listeners |
Constructor Summary | |
FileLogWriter()
Creates a new FileLogWriter instance. |
Method Summary | |
boolean |
archiveFile(java.lang.String sourceZipFile,
java.lang.String fileName)
The file before getting deleted from the logs directory, is moved to Archive. |
void |
close()
This method will close the stream that are opened and releases any resources that are associated with the stream. |
void |
err(java.lang.String message,
java.lang.Throwable exception)
Prints this Throwable exception and its error message to the log file.When the error messages and the Throwable is passed to this method, the messages and stack trace belonging to it will be printed into the file. |
void |
flush()
This method transfers the logout and logerror messages from memory in to the file and cleans the memory area. |
java.lang.String |
getArchiveDirectory()
This will return the Archive directory.The Archive directory mentioned in the logging configuration file will be returned. |
boolean |
getArchiveStatus()
This will return the Archive status.The current Archive status will be retreived. |
int |
getBufferSize()
The buffer size is retreived.Since the buffer size can be changed at runtime, this method returns the currently modified size of the buffer. |
java.lang.String |
getFileName()
This will return the log file name . |
java.lang.String |
getFlushMode()
Used to get the flush mode on which this instance is operating. |
java.lang.String |
getLogDirectory()
This will return the log directory. |
int |
getMaxFileCount()
This will return the maximum file count. |
int |
getMaxLineCount()
This will return the maximum lines .The maximum number of lines per file that is used currently can be retreived using this method. |
void |
init(LogWriterProperties prop)
For initializing implementation class with required properties. |
void |
out(java.lang.String message)
This method writes the log messages to the current file. |
void |
setArchiveStatus(boolean archiveStatus)
This will Set the archive status at runtime.If the status is true , then deleted file will be moved to the archive else it will not be moved to archive. |
void |
setBufferSize(int size)
The buffer size is set for the corresponding buffer type . |
void |
setFlushMode(java.lang.String type)
This will set the flush mode at runtime. |
void |
setMaxFileCount(int no)
This will Set the maximum file count at runtime.The maximum number of files of same type under the logs directory mentioned in the logging configuration file can be changed at runtime by setting the number of lines using this method. |
void |
setMaxLineCount(int no)
This will Set the maximum line count at runtime.The maximum number of lines per file mentioned in the logging configuration file can be changed at runtime by setting the number of lines using this method. |
Methods inherited from class com.adventnet.afp.log.AbstractLogWriter |
addPropertyChangeListener, getInstanceName, removePropertyChangeListener |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FileLogWriter()
FileLogWriter
instance.Method Detail |
public void init(LogWriterProperties prop) throws LogException
init
in class AbstractLogWriter
prop
- Properties containing information read from the logging configuration file.LogException
- if an error occurs during initializationpublic boolean archiveFile(java.lang.String sourceZipFile, java.lang.String fileName)
sourceZipFile
- The zip file where the files are stored.fileName
- The file which will be moved to Archive before getting deleted.public void out(java.lang.String message)
message
- A string to be logged.public void err(java.lang.String message, java.lang.Throwable exception)
exception
- Throwablemessage
- Error message to be logged.public void flush() throws LogException
LogException
- if an error occurs while flushing the contents of the writerpublic void close() throws LogException
LogException
- if an error occurs while closing the writerpublic void setFlushMode(java.lang.String type)
type
- Type of buffering either "Auto" or "Manual"public java.lang.String getFlushMode()
public void setBufferSize(int size)
size
- The buffer size for the corresponding buffer type.public int getBufferSize()
public java.lang.String getFileName()
public java.lang.String getLogDirectory()
public java.lang.String getArchiveDirectory()
public void setMaxLineCount(int no)
no
- The size of the maximum line count.public int getMaxLineCount()
public void setMaxFileCount(int no)
no
- The size of the maximum file count.public int getMaxFileCount()
public void setArchiveStatus(boolean archiveStatus)
archiveStatus
- The status of the Archive which is passed as boolean.public boolean getArchiveStatus()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |