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, LoggingRuntime
GFFileHandler publishes formatted log Messages to a FILE.- Author:
- Jerome Dochez, Carla Mott
-
-
Field Summary
Fields Modifier and Type Field Description static int
DISABLE_LOG_FILE_ROTATION_VALUE
protected ServerEnvironmentImpl
env
protected String
logFileProperty
protected static String
LOGS_DIR
static int
MINIMUM_ROTATION_LIMIT_VALUE
-
Constructor Summary
Constructors Constructor Description GFFileHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addLogEventListener(LogEventListener listener)
void
cleanUpHistoryLogFiles()
cleanup the history log file based on attributes set under logging.properties file".protected String
evaluateFileName()
File
getCurrentLogFile()
A simple getter to access the current log file written by this FileHandler.protected File
getLogFileName()
void
informLogEventListeners(LogEvent logEvent)
Broadcast the log event to registered listeners.void
log()
5005 Retrieves the LogRecord from our Queue and store them in the filevoid
postConstruct()
void
preDestroy()
void
publish(LogRecord record)
Publishes the logrecord storing it in our queueboolean
removeLogEventListener(LogEventListener listener)
void
rotate()
A Simple rotate method to close the old file and start the new one when the limit is reached.void
setCompressionOnRotation(boolean compressionOnRotation)
void
setExcludeFields(String excludeFields)
void
setFileHandlerFormatter(String fileHandlerFormatter)
void
setFlushFrequency(int flushFrequency)
void
setLogFile(String fileName)
void
setLogStandardStreams(boolean logStandardStreams)
void
setLogToFile(boolean logToFile)
void
setMaxHistoryFiles(int maxHistoryFiles)
void
setMultiLineMode(boolean multiLineMode)
void
setRotationLimitAttrValue(Integer rotationLimitAttrValue)
void
setRotationOnDateChange(boolean rotationOnDateChange)
void
setRotationTimeLimitValue(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:
postConstruct
in interfaceorg.glassfish.hk2.api.PostConstruct
-
evaluateFileName
protected String evaluateFileName()
-
preDestroy
public void preDestroy()
- Specified by:
preDestroy
in interfaceorg.glassfish.hk2.api.PreDestroy
-
getCurrentLogFile
public File getCurrentLogFile()
A simple getter to access the current log file written by this FileHandler.- Specified by:
getCurrentLogFile
in 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:
publish
in 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:LogEventBroadcaster
Broadcast the log event to registered listeners.- Specified by:
informLogEventListeners
in 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)
-
-