public final class Configuration
extends java.lang.Object
By default, the configuration will be loaded from tinylog.properties
in the default package. Another
configuration file can be loaded by setting the system property tinylog.configuration
. The configuration file
can be a resource in the classpath, a file from file system or an URL
Alternately configuration properties can be set via system properties. These properties must be prefixed by
"tinylog.
". For example: "level = debug
" becomes "tinylog.level=debug
". If a configuration
property exists as system property and in configuration file, the system property will win.
Modifier and Type | Method | Description |
---|---|---|
static java.lang.String |
get(java.lang.String key) |
Gets a configuration property.
|
static java.util.Map<java.lang.String,java.lang.String> |
getChildren(java.lang.String key) |
Gets all child properties for a parent property.
|
static java.util.Locale |
getLocale() |
Gets the global locale.
|
static java.util.Map<java.lang.String,java.lang.String> |
getSiblings(java.lang.String prefix) |
Gets all siblings with a defined prefix.
|
static boolean |
isEscapingEnabled() |
Checks whether escaping is enabled or disabled.
|
static void |
replace(java.util.Map<java.lang.String,java.lang.String> configuration) |
Replaces the current configuration by a new one.
|
static void |
set(java.lang.String key,
java.lang.String value) |
Sets a property.
|
public static java.util.Locale getLocale()
locale
or Locale.ROOT
if no locale is configuredpublic static boolean isEscapingEnabled()
true
if escaping is enabled, otherwise false
public static java.lang.String get(java.lang.String key)
key
- Case-sensitive key of propertynull
public static java.util.Map<java.lang.String,java.lang.String> getSiblings(java.lang.String prefix)
Example:
getSiblings("writer")
will return properties with the keys writer
as well as writerTest
but not with the key writer.test
. Dots after a prefix ending with an at sign will be not handled as
children. Therefore, getSiblings("level@")
will return a property with the key level@com.test
.
prefix
- Case-sensitive prefix for keyspublic static java.util.Map<java.lang.String,java.lang.String> getChildren(java.lang.String key)
For example: getChildren("writer")
will return the property writer.level
as level
.
key
- Case-sensitive key of parent propertypublic static void set(java.lang.String key, java.lang.String value) throws java.lang.UnsupportedOperationException
Configuration properties must be set before calling any logging methods. If the framework has been initialized
once, the configuration is immutable and further configuration changes will throw an UnsupportedOperationException
.
key
- Name of the propertyvalue
- Value of the propertyjava.lang.UnsupportedOperationException
- Configuration has already been applied and is frozenpublic static void replace(java.util.Map<java.lang.String,java.lang.String> configuration) throws java.lang.UnsupportedOperationException
Configuration properties must be set before calling any logging methods. If the framework has been initialized
once, the configuration is immutable and further configuration changes will throw an UnsupportedOperationException
.
configuration
- New configurationjava.lang.UnsupportedOperationException
- Configuration has already been applied and is frozenCopyright © 2020. All rights reserved.