Class Initializer

Object
Initializer

public class Initializer extends Object
Loads a logging configuration file using Java logging syntax augmented with Apache SIS extensions. The "java​.util​.logging​.config​.file" system property must be set to the path of a properties file containing configuration in the format described by Log­Manager. This class applies the following filtering on the configuration file:
  • Changes in "java​.util​.logging​.File­Handler​.pattern" property value:
    • Replace %p by the parent directory of the logging configuration file.

Example

Given an application with the following directory structure:
application
 ├─ conf/
 │  └─ logging.properties
 └─ log/
If the logging​.properties contains the following line:
java.util.logging.FileHandler.pattern = %p/log/myapp.log
Then the %p characters of that property value will be replaced by the path to the application directory, thus allowing the application to log in the log/ sub-directory. Other special components such as %t, %h, %g or %u are handled as usual (i.e. as documented by File­Handler).

Usage

This class should not referenced directly by other Java code. Instead, it should be specified at JVM startup time like below:
java -Djava.util.logging.config.class=org.apache.sis.util.logging.Initializer \
     -Djava.util.logging.config.file=path/to/my/application/conf/logging.properties
See for example the bin/sis shell script in Apache SIS binary distribution.
Since:
1.3
See Also:
  • Constructor Details

    • Initializer

      public Initializer() throws IOException
      Configures Java logging using a filtered configuration file. This constructor gets the configuration file referenced by the "java​.util​.logging​.config​.file" system property, applies the filtering described in class javadoc, then gives the filtered configuration to Log­Manager​.read­Configuration(Input­Stream).

      This constructor should not be invoked directly. See class javadoc for usage example.

      Throws:
      IOException - if an error occurred while reading the configuration file.