Class LogHelper
java.lang.Object
nl.colorize.util.LogHelper
Helper methods for initializing and configuring
java.util.logging
loggers programmatically. A default logging configuration is automatically
applied to all logger in the nl.colorize namespace.-
Method Summary
Modifier and TypeMethodDescriptionstatic HandlercreateCallbackHandler(Consumer<Throwable> callback) Creates a log handler that will invoke the specified callback function for every log message that contains an attachedThrowable.static FormatterCreates a log message formatter that uses a compact format with log records only taking up a single line.static ConsoleHandlerCreates a log handler that will log tostderr.static FileHandlercreateFileHandler(File logfile) Creates a log handler that will log to the specified file using the platform's default character encoding.static FileHandlercreateFileHandler(File logfile, Charset encoding) Creates a log handler that will log to the specified file.static HandlercreateStringHandler(StringWriter stringWriter) Creates a log handler that will write log messages to the specifiedStringWriterand uses a compact formatter.static HandlercreateStringHandler(StringWriter stringWriter, Formatter formatter) Creates a log handler that will write log messages to the specifiedStringWriter.static LoggerObtains the logger with the name of the specified class.static LoggerObtains the logger with the specified name.static StringReturns the strack trace for the specified exception as a string.
-
Method Details
-
getLogger
-
getLogger
-
createConsoleHandler
Creates a log handler that will log tostderr. The handler will use the platform's default character encoding. -
createFileHandler
Creates a log handler that will log to the specified file using the platform's default character encoding.- Throws:
IllegalArgumentException- if the file is not writeable.
-
createFileHandler
Creates a log handler that will log to the specified file.- Throws:
IllegalArgumentException- if the file is not writeable.
-
createCallbackHandler
-
createStringHandler
Creates a log handler that will write log messages to the specifiedStringWriter. -
createStringHandler
Creates a log handler that will write log messages to the specifiedStringWriterand uses a compact formatter. -
createCompactFormatter
Creates a log message formatter that uses a compact format with log records only taking up a single line. This makes it easier to process log files in other tools, or scan them manually.Messages are logged using the default time zone for date and time. See
Platform.getDefaultTimeZone()for more information. -
getStackTrace
-