public class FileHandler extends Handler
The FileHandler can either write to a specified file, or it can write to a rotating set of files.
For a rotating set of files, as each file reaches the limit ( LogConstants.MAX_FILE_SIZE), it is closed, rotated out, and a new file opened. Successively older files and named by adding "-1", "-2", etc., * to the base filename. The Locking mechanism is much more relaxed (in JDK's FileHandler an exclusive lock is created on the file till the handler is closed which makes reading impossible)
Constructor and Description |
---|
FileHandler(String fileName)
Creates a new FileHandler.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Flush any buffered messages and Close all the files.
|
void |
flush() |
protected void |
nonBlockingFlush()
Flush any buffered messages.
|
void |
publish(LogRecord lrecord)
Format and publish a LogRecord.
|
void |
setEncoding(String encoding)
Set (or change) the character encoding used by this Handler.
|
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setErrorManager, setFilter, setFormatter, setLevel
public FileHandler(String fileName)
fileName
- The filename associate with file handler.public void setEncoding(String encoding) throws SecurityException, UnsupportedEncodingException
setEncoding
in class Handler
encoding
- The name of a supported character encoding.
May be null, to indicate the default platform encoding.SecurityException
- if a security manager exists and if
the caller does not have
LoggingPermission("control").UnsupportedEncodingException
- if the named encoding is
not supported.public void close()
public void publish(LogRecord lrecord)
This FileHandler is associated with a Formatter, which has to format the LogRecord according to ELF and return back the string formatted as per ELF. This method first checks if the header is already written to the file, if not, gets the header from the Formatter and writes it at the beginning of the file.
protected void nonBlockingFlush()
Copyright © 2010–2025 Open Identity Platform Community. All rights reserved.