Modifier and Type | Method | Description |
---|---|---|
boolean |
activate() |
Activate the configuration.
|
Configurator |
addWriter(Writer writer) |
Add an additional writer for outputting the created log entries.
|
Configurator |
addWriter(Writer writer,
String formatPattern) |
Add an additional writer for outputting the created log entries.
|
Configurator |
addWriter(Writer writer,
Level level) |
Add an additional writer for outputting the created log entries.
|
Configurator |
addWriter(Writer writer,
Level level,
String formatPattern) |
Add an additional writer for outputting the created log entries.
|
static Configurator |
currentConfig() |
Create a new configurator, based on the current configuration.
|
static Configurator |
defaultConfig() |
Create a new configurator, based on the default configuration.
|
Configurator |
formatPattern(String formatPattern) |
Set the format pattern for log entries.
|
static Configurator |
fromFile(File file) |
Load a properties file from file system.
|
static Configurator |
fromMap(Map<String,?> map) |
Load properties from a
Map . |
static Configurator |
fromResource(String file) |
Load a properties file from classpath.
|
static Configurator |
fromStream(InputStream stream) |
Load a properties file from an input stream.
|
static Configurator |
fromURL(URL url) |
Load a properties file from a URL.
|
Configurator |
level(Class<?> classObject,
Level level) |
Set a custom severity level for a class.
|
Configurator |
level(Package packageObject,
Level level) |
Set a custom severity level for a package.
|
Configurator |
level(String packageOrClass,
Level level) |
Set a custom severity level for a package or class.
|
Configurator |
level(Level level) |
Change the severity level.
|
Configurator |
locale(Locale locale) |
Set the locale that is used to render format patterns for log entries.
|
Configurator |
maxStackTraceElements(int maxStackTraceElements) |
Set the limit of stack traces for exceptions (default is 40).
|
Configurator |
removeAllWriters() |
Remove all writers.
|
Configurator |
removeWriter(Writer writer) |
Remove a writer.
|
Configurator |
resetCustomLevels() |
Reset all custom severity levels (to use the default severity level again).
|
static void |
shutdownConfigurationObserver(boolean wait) |
Manually shutdown of configuration observer.
|
static void |
shutdownWritingThread(boolean wait) |
Manually shutdown of writing thread.
|
Configurator |
writer(Writer writer) |
Set a writer to output created log entries.
|
Configurator |
writer(Writer writer,
String formatPattern) |
Set a writer to output created log entries.
|
Configurator |
writer(Writer writer,
Level level) |
Set a writer to output created log entries.
|
Configurator |
writer(Writer writer,
Level level,
String formatPattern) |
Set a writer to output created log entries.
|
Configurator |
writingThread(boolean enable) |
The writing thread can writes log entries asynchronously.
|
Configurator |
writingThread(int priority) |
The writing thread can writes log entries asynchronously.
|
Configurator |
writingThread(String threadToObserve) |
The writing thread can writes log entries asynchronously.
|
Configurator |
writingThread(String threadToObserve,
int priority) |
The writing thread can writes log entries asynchronously.
|
public static Configurator defaultConfig()
public static Configurator currentConfig()
public static Configurator fromResource(String file) throws IOException
file
- Path to file to loadIOException
- Failed to load and read filepublic static Configurator fromFile(File file) throws IOException
file
- File to loadIOException
- Failed to load and read filepublic static Configurator fromStream(InputStream stream) throws IOException
stream
- Properties fileIOException
- Failed to read from streampublic static Configurator fromURL(URL url) throws IOException
url
- Properties fileIOException
- Failed to read from URLpublic static Configurator fromMap(Map<String,?> map)
Map
.map
- Map with configurationpublic Configurator level(Level level)
level
- New severity levelpublic Configurator level(Package packageObject, Level level)
packageObject
- Packagelevel
- The severity level (or null
to reset it to the default severity level)public Configurator level(Class<?> classObject, Level level)
classObject
- Classlevel
- The severity level (or null
to reset it to the default severity level)public Configurator level(String packageOrClass, Level level)
packageOrClass
- Name of a package or classlevel
- The severity level (or null
to reset it to the default severity level)public Configurator resetCustomLevels()
public Configurator formatPattern(String formatPattern)
"{date:yyyy-MM-dd HH:mm:ss} [{thread}] {class}.{method}()\n{level}: {message}"
is the default format
pattern. The date format pattern is compatible with SimpleDateFormat
.formatPattern
- Format pattern for log entries (or null
to reset to default)SimpleDateFormat
public Configurator locale(Locale locale)
locale
- Locale for format patternspublic Configurator writer(Writer writer)
writer
- Writer to set (can be null
to disable any output)public Configurator writer(Writer writer, Level level)
writer
- Writer to set (can be null
to disable any output)level
- Writer will output entries with the same or higher severity levelpublic Configurator writer(Writer writer, String formatPattern)
writer
- Writer to set (can be null
to disable any output)formatPattern
- Format pattern to use instead of the global format pattern to render log entriespublic Configurator writer(Writer writer, Level level, String formatPattern)
writer
- Writer to set (can be null
to disable any output)level
- Writer will output entries with the same or higher severity levelformatPattern
- Format pattern to use instead of the global format pattern to render log entriespublic Configurator addWriter(Writer writer)
writer
- Writer to addpublic Configurator addWriter(Writer writer, Level level)
writer
- Writer to addlevel
- Writer will output entries with the same or higher severity levelpublic Configurator addWriter(Writer writer, String formatPattern)
writer
- Writer to addformatPattern
- Format pattern to use instead of the global format pattern to render log entriespublic Configurator addWriter(Writer writer, Level level, String formatPattern)
writer
- Writer to set (can be null
to disable any output)level
- Writer will output entries with the same or higher severity levelformatPattern
- Format pattern to use instead of the global format pattern to render log entriespublic Configurator removeWriter(Writer writer)
writer
- Writer to removepublic Configurator removeAllWriters()
public Configurator writingThread(boolean enable)
enable
- true
to enable the writing thread, false
to disable itpublic Configurator writingThread(int priority)
priority
- Priority of the writing thread (must be between Thread.MIN_PRIORITY
and
Thread.MAX_PRIORITY
)public Configurator writingThread(String threadToObserve)
threadToObserve
- Name of the tread to observe (e.g. "main" for the main thread) or null
to disable
automatic shutdownpublic Configurator writingThread(String threadToObserve, int priority)
threadToObserve
- Name of the tread to observe (e.g. "main" for the main thread) or null
to disable
automatic shutdownpriority
- Priority of the writing thread (must be between Thread.MIN_PRIORITY
and
Thread.MAX_PRIORITY
)public Configurator maxStackTraceElements(int maxStackTraceElements)
maxStackTraceElements
- Limit of stack tracespublic boolean activate()
true
if the configuration has been successfully activated, false
if the
activation failedpublic static void shutdownWritingThread(boolean wait)
wait
- true
to wait for the successful shutdown, false
for an asynchronous shutdownpublic static void shutdownConfigurationObserver(boolean wait)
wait
- true
to wait for the successful shutdown, false
for an asynchronous shutdownCopyright © 2019. All rights reserved.