Class FileLogHandler
- Direct Known Subclasses:
AsyncFileLogHandler
Handler that appends one line per LogRecord using the configured Formatter
(default SimpleFormatter when FileLogHandlerConfig.formatter() is null).
Optional rotation renames the current file to name.log.0, shifts older segments, and starts a new file.
publish(java.util.logging.LogRecord) holds the read side of writerLock while a record is written. Rotation and close()
hold the write side: while Files.move(java.nio.file.Path, java.nio.file.Path, java.nio.file.CopyOption...) runs, other threads block (async rotation is out of scope).
Byte writes themselves are serialized on streamLock, because the stream is not safe for concurrent use.
-
Constructor Summary
ConstructorsConstructorDescriptionFileLogHandler(Path logFile) FileLogHandler(Path logFile, FileLogHandlerConfig config) -
Method Summary
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
-
Constructor Details
-
FileLogHandler
-
FileLogHandler
-
-
Method Details
-
publish
Formats the record, rotates when the calendar day or the size limit says so, then appends one line. Formatting runs before rotation, so a formatter failure does not rotate the file.Tomcat reference: https://github.com/apache/tomcat/blob/05b5d70555068a6647226e9924b2d7f1b9978b03/java/org/apache/juli/FileHandler.java
-
flush
public void flush()Flushes the open writer. Does nothing when the file has not been opened yet.Tomcat reference: https://github.com/apache/tomcat/blob/05b5d70555068a6647226e9924b2d7f1b9978b03/java/org/apache/juli/FileHandler.java
-
close
public void close()Closes the open log file.Tomcat reference: https://github.com/apache/tomcat/blob/05b5d70555068a6647226e9924b2d7f1b9978b03/java/org/apache/juli/FileHandler.java
-