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.Map<java.lang.String,java.lang.String> |
getSiblings(java.lang.String prefix) |
Gets all siblings with a defined prefix.
|
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.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
[email protected].
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)
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 be just ignored.
key
- Name of the propertyvalue
- Value of the propertypublic static void replace(java.util.Map<java.lang.String,java.lang.String> configuration)
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 be just ignored.
configuration
- New configurationCopyright © 2018. All rights reserved.