|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.andynaz.log.Config
public class Config
Configuration of a Logger
.
A configuration can be used by various loggers.
Wrap alla the properties for a logger in a Properties
object
(different from the one it is constructed), such as the log level or if the
date has to be shown.
Properties from the logger can be obtained using the getProperty(java.lang.String)
method.
Each logger takes the properties it needs from the configuration on creation time. If a property is not found, it should use a default value. For the list of the values searched by each kind of logger, look at its documentation.
The class has also a shared config (can be thougth as a default one) used
to create logger without a specified configuration. This configuration can be
initialized using the vatious init() methods and can be retrived
using the getConfig()
method.
Constructor Summary | |
---|---|
Config(Properties props)
Creates a new configuration. |
Method Summary | |
---|---|
static Config |
getConfig()
Returns the shared configuration. |
String |
getProperty(String propName)
Get a property value. |
static void |
init()
Inizialize the shared configuration. |
static void |
init(Properties props)
Inizialize the shared configuration with a Properties object. |
static void |
init(String file)
Inizialize the shared configuration with a file of properties. |
void |
list()
List all the properties on the standard output. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Config(Properties props)
A config is constructed using a Properties object; it takes all the properties starting with "andyLog." and stores them in an internal Properties object, without the prefix (for instance, the property "andyLog.level" is stored as "level").
props
- set of propertiesMethod Detail |
---|
public String getProperty(String propName)
propName
- name of the property
public static void init(Properties props)
Properties
object.
This method can be inviked several times during execution; only the last configuration is saved.
props
- properties to readpublic static void init(String file)
This method can be inviked several times during execution; only the last configuration is saved.
file
- path to the properties filepublic static void init()
This method can be inviked several times during execution; only the last configuration is saved.
public static Config getConfig()
By default the object returned has an empty list of properties; to initialize the configuration use one of the init() methods.
public void list()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |