Use the following piece of code (usually in the initialization stage) to load the configuration data from a “.properties“ file:
_propConfig = new PropertiesConfigurator( new File("logging.properties")); _propConfig.configure(); |
The example shown above reads from a “.properties“ file named logging.properties in the current directory, and triggers the configuration as specified in the file.
Each application stores its “.properties” files in its own directory. If the logging tool cannot locate the “.properties” file, an error message is prompted and the application continues to run without logging being switched on (assuming all configuration is done through the “.properties file”).
For more information about the error handling concept, see Administrative Issues.
You can specify a periodic value (in minutes) to read and load the “.properties” file again and to scan for a new configuration automatically. This feature is useful especially in cases when a log console is available.
For example, to reload the properties file for every 30 minutes, use:
_propConfig.setPeriodicity(30); |