public final class Configuration extends 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 and Description |
---|---|
static String |
get(String key)
Gets a configuration property.
|
static Map<String,String> |
getChildren(String key)
Gets all child properties for a parent property.
|
static Locale |
getLocale()
Gets the global locale.
|
static Map<String,String> |
getSiblings(String prefix)
Gets all siblings with a defined prefix.
|
static boolean |
isEscapingEnabled()
Checks whether escaping is enabled or disabled.
|
static boolean |
isFrozen()
Checks whether the configuration is already frozen.
|
static void |
replace(Map<String,String> configuration)
Replaces the current configuration by a new one.
|
static void |
set(String key,
String value)
Sets a property.
|
public static Locale getLocale()
locale
or Locale.ROOT
if no locale is configuredpublic static boolean isEscapingEnabled()
true
if escaping is enabled, otherwise false
public static String get(String key)
key
- Case-sensitive key of propertynull
public static Map<String,String> getSiblings(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 Map<String,String> getChildren(String key)
For example: getChildren("writer")
will return the property writer.level
as level
.
key
- Case-sensitive key of parent propertypublic static void set(String key, String value) throws 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 propertyUnsupportedOperationException
- Configuration has already been applied and is frozenpublic static void replace(Map<String,String> configuration) throws 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 configurationUnsupportedOperationException
- Configuration has already been applied and is frozenpublic static boolean isFrozen()
true
if the configuration is frozen, otherwise false
Copyright © 2020. All rights reserved.