public class LoggingConfiguration extends Object
This class is necessary due to a JDK bug / spec flaw, that requires that a
absolute path for java.util.logging.config.file
system property.
A relative path is required in most environments. This class provides tools
to read a log configuration from a relative path.
The log-Levels you can use in the properties file are:
The LoggingConfiguration
supports following properties, which must be
set in the System
properties. To change the properties in
Runtime in a type-safe manner you may use the StringSystemProperty
reference hold by SYSTEM_PROPERTY_CONFIG_FILE
.
Name | Type | Description |
---|---|---|
xdev.util.logging.config.file | String |
The xdev.util.logging.config.file System property can be used to
specify a properties file (in java.util.Properties format). The initial
logging configuration will be read from this file.
If the property is not defined then, the LogManager will read its initial
configuration from a properties file "lib/logging.properties" in the JRE
directory. |
LogManager
Modifier and Type | Field and Description |
---|---|
static StringSystemProperty |
SYSTEM_PROPERTY_CONFIG_FILE
The
xdev.util.logging.config.file System property can be
used to specify a properties file (in java.util.Properties format). |
Constructor and Description |
---|
LoggingConfiguration() |
Modifier and Type | Method and Description |
---|---|
static void |
readConfiguration()
Reinitialize the logging properties and reread the logging configuration.
|
static void |
readConfiguration(String path)
Reinitialize the logging properties and reread the logging configuration
from the given path, which should be in java.util.Properties format.
|
public static final StringSystemProperty SYSTEM_PROPERTY_CONFIG_FILE
xdev.util.logging.config.file
System property can be
used to specify a properties file (in java.util.Properties format). The
initial logging configuration will be read from this file.
If the property is not defined then, the LogManager will read its initial
configuration from a properties file "lib/logging.properties" in the JRE
directory.public static void readConfiguration(String path) throws SecurityException
Any log level definitions in the new configuration file will be applied using Logger.setLevel(), if the target Logger exists.
path
- relative path to a properties file (in java.util.Properties
format) to read properties fromSecurityException
- if a security manager exists and if the caller does not
have LoggingPermission("control").public static void readConfiguration()
The same rules are used for locating the configuration properties as are
used at startup (SYSTEM_PROPERTY_CONFIG_FILE
). So normally the
logging properties will be re-read from the same file that was used at
startup.
Any log level definitions in the new configuration file will be applied using Logger.setLevel(), if the target Logger exists.
This method may do nothing if SYSTEM_PROPERTY_CONFIG_FILE
is
null
or empty.
A PropertyChangeEvent will be fired after the properties are read.
SYSTEM_PROPERTY_CONFIG_FILE
Copyright © 2003–2021 XDEV Software. All rights reserved.