Class FileHandler
- java.lang.Object
-
- java.util.logging.Handler
-
- com.sun.identity.log.handlers.FileHandler
-
public class FileHandler extends Handler
This FileHandler is very much similar to thejava.util.logging.FileHandler . 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 Summary
Constructors Constructor Description FileHandler(String fileName)
Creates a new FileHandler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setErrorManager, setFilter, setFormatter, setLevel
-
-
-
-
Constructor Detail
-
FileHandler
public FileHandler(String fileName)
Creates a new FileHandler. It takes a string parameter which represents file name. When this constructor is called a new file to be created. Assuming that the fileName logger provides is the timestamped fileName.- Parameters:
fileName
- The filename associate with file handler.
-
-
Method Detail
-
setEncoding
public void setEncoding(String encoding) throws SecurityException, UnsupportedEncodingException
Set (or change) the character encoding used by this Handler. The encoding should be set before any LogRecords are written to the Handler.- Overrides:
setEncoding
in classHandler
- Parameters:
encoding
- The name of a supported character encoding. May be null, to indicate the default platform encoding.- Throws:
SecurityException
- if a security manager exists and if the caller does not have LoggingPermission("control").UnsupportedEncodingException
- if the named encoding is not supported.
-
close
public void close()
Flush any buffered messages and Close all the files.
-
publish
public void publish(LogRecord lrecord)
Format and publish a LogRecord.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.
-
nonBlockingFlush
protected void nonBlockingFlush()
Flush any buffered messages.
-
-