|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
jrunx.kernel.ServiceAdapter
|
+--jrunx.kernel.ServicePartition
|
+--jrunx.kernel.ConfigurableServicePartition
|
+--jrunx.logger.LogEventHandler
|
+--jrunx.logger.FileLogEventHandler
Sends log events to a file.
| Field Summary | |
protected long |
closeDelay
|
protected java.lang.String |
currentFilename
|
static long |
DEFAULT_CLOSE_DELAY
|
static java.lang.String |
DEFAULT_FILENAME
|
static int |
DEFAULT_ROTATION_FILES
|
static java.lang.String |
DEFAULT_ROTATION_SIZE
|
protected long |
lastWriteTime
|
protected static java.lang.String |
newline
|
protected static int |
newlineLen
|
protected java.io.PrintWriter |
out
|
protected boolean |
scheduled
|
| Fields inherited from class jrunx.kernel.ServicePartition |
sortedServices |
| Fields inherited from class jrunx.kernel.ServiceAdapter |
DEFAULT_DEACTIVATED, DEFAULT_DOMAIN, DOMAIN_NAME_SEPARATOR, DOMAIN_NAME_SUFFIX, domainName, jndiBindable, LOGGER_CACHE_TIME, SCHEDULER_SERVICE, SECURITY_MANAGER, server, status, TRANSACTION_MANAGER |
| Fields inherited from interface jrunx.kernel.Service |
INITIALIZED, STARTED, STARTING, STOPPED, STOPPING, UNINITIALIZED |
| Constructor Summary | |
FileLogEventHandler()
|
|
| Method Summary | |
protected void |
calculateRotationSize()
|
protected void |
checkForRotation(LogEvent event,
java.lang.String msg)
Check to see if a file rotation is necessary |
protected void |
closeFile()
|
static java.lang.String |
computeLocalizedLogFileHeading(java.lang.String format)
|
static java.lang.String |
expandServerDate(java.lang.String formatString)
|
long |
getCloseDelay()
Gets the number of milliseconds to wait before closing the physical file. |
boolean |
getDeleteOnExit()
Gets the value of the delete on exit flag. |
java.lang.String |
getFilename()
Gets the name of the file to be used for logging |
long |
getFileSize()
Gets the size of the file to be used for logging |
java.lang.String |
getHeading()
Gets the heading that will be written into each new file that is created. |
int |
getRotationFiles()
Gets the number of rotated files to maintain. |
protected java.lang.String |
getRotationName(java.lang.String filename,
int n)
Format a rotation filename given the original name and the rotation number |
java.lang.String |
getRotationSize()
Gets the rotation size of the file |
int |
getRotationSizeValue()
|
boolean |
logEvent(LogEvent event)
|
protected java.io.PrintWriter |
openFile(java.lang.String fname)
Open the given file. |
protected boolean |
removeFile(java.lang.String name)
Attempt to delete the given file |
protected boolean |
renameFile(java.lang.String name,
java.lang.String newName)
Attempt to rename the given file |
void |
run()
|
void |
setCloseDelay(long delay)
Sets the number of milliseconds to wait before closing the physical file. |
void |
setDeleteOnExit(boolean deleteOnExit)
Sets the flag for deleting log files from previous server runs. |
void |
setFilename(java.lang.String filename)
Sets the name of the file to be used for logging |
void |
setHeading(java.lang.String heading)
Sets the heading that will be written into each new file that is created. |
void |
setRotationFiles(int files)
Specify the number of rotated files to maintain. |
void |
setRotationSize(java.lang.String size)
Sets the rotation size of the file. |
void |
start()
Every service other than mere data collections should start |
void |
stop()
Every service other than mere data collections should stop |
| Methods inherited from class jrunx.logger.LogEventHandler |
clearBuffer, flush, getFormat, log, setFormat |
| Methods inherited from class jrunx.kernel.ConfigurableServicePartition |
destroy, destroyServices, init, initServices, loadAndInit, loadChildren, setChildElements, startServices, stopServices |
| Methods inherited from class jrunx.kernel.ServicePartition |
addService, addService, getServices, invokeChain, iterator, removeService, removeService |
| Methods inherited from interface jrunx.logger.LogEventHandlerMBean |
flush, getFormat, log, setFormat |
| Methods inherited from interface jrunx.kernel.ServiceMBean |
bind, getBindToJNDI, getDeactivated, getDomainName, getJRunService, getLogger, getName, getParentService, getServerName, requestServer, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, unbind |
| Methods inherited from interface jrunx.kernel.Service |
destroy, getStatus, init, updateStatus |
| Methods inherited from interface jrunx.kernel.ServicePartitionMBean |
addService, addService, iterator, removeService, removeService |
| Field Detail |
public static final java.lang.String DEFAULT_FILENAME
public static final java.lang.String DEFAULT_ROTATION_SIZE
public static final int DEFAULT_ROTATION_FILES
public static final long DEFAULT_CLOSE_DELAY
protected static java.lang.String newline
protected static int newlineLen
protected long closeDelay
protected long lastWriteTime
protected java.lang.String currentFilename
protected java.io.PrintWriter out
protected boolean scheduled
| Constructor Detail |
public FileLogEventHandler()
| Method Detail |
public void setDeleteOnExit(boolean deleteOnExit)
setDeleteOnExit in interface FileLogEventHandlerMBeandeleteOnExit - The delete on exit flag.public boolean getDeleteOnExit()
getDeleteOnExit in interface FileLogEventHandlerMBeanpublic void setFilename(java.lang.String filename)
FileLogEventHandlerMBeansetFilename in interface FileLogEventHandlerMBeanjrunx.logger.FileLogEventHandlerMBeanfilename - The filenamepublic java.lang.String getFilename()
FileLogEventHandlerMBeangetFilename in interface FileLogEventHandlerMBeanjrunx.logger.FileLogEventHandlerMBeanpublic long getFileSize()
FileLogEventHandlerMBeangetFileSize in interface FileLogEventHandlerMBeanjrunx.logger.FileLogEventHandlerMBeanpublic void setRotationSize(java.lang.String size)
FileLogEventHandlerMBeanThe file number will be inserted before an extension if one exists (such as event.log -> event_1.log); otherwise the file number will be appended to the file (such as event -> event_1).
The default rotation size is 100000.
Rotation sizes can include a suffix of 'm' or 'k', for megabytes or kilobytes. For example, 100k or 1m. The suffix is case insensitive.
setRotationSize in interface FileLogEventHandlerMBeanjrunx.logger.FileLogEventHandlerMBeansize - The rotation sizepublic java.lang.String getRotationSize()
FileLogEventHandlerMBeangetRotationSize in interface FileLogEventHandlerMBeanjrunx.logger.FileLogEventHandlerMBeanpublic int getRotationSizeValue()
protected void calculateRotationSize()
public void setRotationFiles(int files)
FileLogEventHandlerMBeansetRotationFiles in interface FileLogEventHandlerMBeanjrunx.logger.FileLogEventHandlerMBeanfiles - The number of rotation filespublic int getRotationFiles()
FileLogEventHandlerMBeangetRotationFiles in interface FileLogEventHandlerMBeanjrunx.logger.FileLogEventHandlerMBeanpublic void setHeading(java.lang.String heading)
FileLogEventHandlerMBeansetHeading in interface FileLogEventHandlerMBeanjrunx.logger.FileLogEventHandlerMBeanheading - The headingpublic java.lang.String getHeading()
FileLogEventHandlerMBeangetHeading in interface FileLogEventHandlerMBeanjrunx.logger.FileLogEventHandlerMBeanpublic void setCloseDelay(long delay)
FileLogEventHandlerMBeansetCloseDelay in interface FileLogEventHandlerMBeanjrunx.logger.FileLogEventHandlerMBeandelay - The close delay in millisecondspublic long getCloseDelay()
FileLogEventHandlerMBeangetCloseDelay in interface FileLogEventHandlerMBeanjrunx.logger.FileLogEventHandlerMBeanpublic void start()
ServiceAdapterstart in interface Servicestart in class ConfigurableServicePartition
public void stop()
throws java.lang.Exception
ServiceAdapterstop in interface Servicestop in class ConfigurableServicePartitionpublic boolean logEvent(LogEvent event)
logEvent in class LogEventHandler
protected void checkForRotation(LogEvent event,
java.lang.String msg)
event - The log event
into the current logprotected void closeFile()
protected java.io.PrintWriter openFile(java.lang.String fname)
filename - The filename
protected java.lang.String getRotationName(java.lang.String filename,
int n)
protected boolean removeFile(java.lang.String name)
name - The name of the file
protected boolean renameFile(java.lang.String name,
java.lang.String newName)
name - The name of the filenewName - The new name of the filepublic static java.lang.String expandServerDate(java.lang.String formatString)
public static java.lang.String computeLocalizedLogFileHeading(java.lang.String format)
public void run()
run in interface java.lang.Runnable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||