Class GFFileHandler
- java.lang.Object
-
- java.util.logging.Handler
-
- java.util.logging.StreamHandler
-
- com.sun.enterprise.server.logging.GFFileHandler
-
- All Implemented Interfaces:
LogEventBroadcaster,LoggingRuntime,org.glassfish.hk2.api.PostConstruct,org.glassfish.hk2.api.PreDestroy
- Direct Known Subclasses:
PayaraNotificationFileHandler
@Service @Singleton @ContractsProvided({GFFileHandler.class,java.util.logging.Handler.class,LogEventBroadcaster.class,LoggingRuntime.class}) public class GFFileHandler extends StreamHandler implements org.glassfish.hk2.api.PostConstruct, org.glassfish.hk2.api.PreDestroy, LogEventBroadcaster, LoggingRuntimeGFFileHandler publishes formatted log Messages to a FILE.- Author:
- Jerome Dochez, Carla Mott
-
-
Field Summary
Fields Modifier and Type Field Description static intDISABLE_LOG_FILE_ROTATION_VALUEprotected ServerEnvironmentImplenvprotected StringlogFilePropertyprotected static StringLOGS_DIRstatic intMINIMUM_ROTATION_LIMIT_VALUE
-
Constructor Summary
Constructors Constructor Description GFFileHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddLogEventListener(LogEventListener listener)voidcleanUpHistoryLogFiles()cleanup the history log file based on attributes set under logging.properties file".protected StringevaluateFileName()FilegetCurrentLogFile()A simple getter to access the current log file written by this FileHandler.protected FilegetLogFileName()voidinformLogEventListeners(LogEvent logEvent)Broadcast the log event to registered listeners.voidlog()5005 Retrieves the LogRecord from our Queue and store them in the filevoidpostConstruct()voidpreDestroy()voidpublish(LogRecord record)Publishes the logrecord storing it in our queuebooleanremoveLogEventListener(LogEventListener listener)voidrotate()A Simple rotate method to close the old file and start the new one when the limit is reached.voidsetCompressionOnRotation(boolean compressionOnRotation)voidsetExcludeFields(String excludeFields)voidsetFileHandlerFormatter(String fileHandlerFormatter)voidsetFlushFrequency(int flushFrequency)voidsetLogFile(String fileName)voidsetLogStandardStreams(boolean logStandardStreams)voidsetLogToFile(boolean logToFile)voidsetMaxHistoryFiles(int maxHistoryFiles)voidsetMultiLineMode(boolean multiLineMode)voidsetRotationLimitAttrValue(Integer rotationLimitAttrValue)voidsetRotationOnDateChange(boolean rotationOnDateChange)voidsetRotationTimeLimitValue(Long rotationTimeLimitValue)-
Methods inherited from class java.util.logging.StreamHandler
close, flush, isLoggable, setEncoding, setOutputStream
-
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, reportError, setErrorManager, setFilter, setFormatter, setLevel
-
-
-
-
Field Detail
-
DISABLE_LOG_FILE_ROTATION_VALUE
public static final int DISABLE_LOG_FILE_ROTATION_VALUE
- See Also:
- Constant Field Values
-
env
@Inject protected ServerEnvironmentImpl env
-
LOGS_DIR
protected static final String LOGS_DIR
- See Also:
- Constant Field Values
-
MINIMUM_ROTATION_LIMIT_VALUE
public static final int MINIMUM_ROTATION_LIMIT_VALUE
- See Also:
- Constant Field Values
-
logFileProperty
protected String logFileProperty
-
-
Method Detail
-
postConstruct
public void postConstruct()
- Specified by:
postConstructin interfaceorg.glassfish.hk2.api.PostConstruct
-
evaluateFileName
protected String evaluateFileName()
-
preDestroy
public void preDestroy()
- Specified by:
preDestroyin interfaceorg.glassfish.hk2.api.PreDestroy
-
getCurrentLogFile
public File getCurrentLogFile()
A simple getter to access the current log file written by this FileHandler.- Specified by:
getCurrentLogFilein interfaceLoggingRuntime- Returns:
-
cleanUpHistoryLogFiles
public void cleanUpHistoryLogFiles()
cleanup the history log file based on attributes set under logging.properties file". If it is defined with valid number, we only keep that number of history logfiles; If "max_history_files" is defined without value, then default that number to be 10; If "max_history_files" is defined with value 0, any number of history files are kept.
-
rotate
public void rotate()
A Simple rotate method to close the old file and start the new one when the limit is reached.
-
log
public void log()
5005 Retrieves the LogRecord from our Queue and store them in the file
-
publish
public void publish(LogRecord record)
Publishes the logrecord storing it in our queue- Overrides:
publishin classStreamHandler
-
getLogFileName
protected File getLogFileName()
-
addLogEventListener
public boolean addLogEventListener(LogEventListener listener)
-
removeLogEventListener
public boolean removeLogEventListener(LogEventListener listener)
-
informLogEventListeners
public void informLogEventListeners(LogEvent logEvent)
Description copied from interface:LogEventBroadcasterBroadcast the log event to registered listeners.- Specified by:
informLogEventListenersin interfaceLogEventBroadcaster
-
setLogFile
public void setLogFile(String fileName)
-
setLogToFile
public void setLogToFile(boolean logToFile)
-
setRotationOnDateChange
public void setRotationOnDateChange(boolean rotationOnDateChange)
-
setMultiLineMode
public void setMultiLineMode(boolean multiLineMode)
-
setFileHandlerFormatter
public void setFileHandlerFormatter(String fileHandlerFormatter)
-
setExcludeFields
public void setExcludeFields(String excludeFields)
-
setRotationLimitAttrValue
public void setRotationLimitAttrValue(Integer rotationLimitAttrValue)
-
setRotationTimeLimitValue
public void setRotationTimeLimitValue(Long rotationTimeLimitValue)
-
setMaxHistoryFiles
public void setMaxHistoryFiles(int maxHistoryFiles)
-
setFlushFrequency
public void setFlushFrequency(int flushFrequency)
-
setCompressionOnRotation
public void setCompressionOnRotation(boolean compressionOnRotation)
-
setLogStandardStreams
public void setLogStandardStreams(boolean logStandardStreams)
-
-