LibraryLink ToToggle FramesPrintFeedback

Configuring Logging Output

The Java logging utility, java.util.logging, uses handler classes to output log messages. Table 5.1 shows the handlers that are configured in the default logging.properties file.

Table 5.1. Java.util.logging Handler Classes

Handler ClassOutputs to
ConsoleHandler Outputs log messages to the console
FileHandler Outputs log messages to a file

[Important]Important

The handler classes must be on the system classpath in order to be installed by the Java VM when it starts. This is done when you set the Fuse Services Framework environment.

Example 5.2 shows the code for configuring the console logger.


The console handler also supports the configuration properties shown in Example 5.3.

Example 5.3. Console Handler Properties

java.util.logging.ConsoleHandler.level = WARNING 1
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter 2

The configuration properties shown in Example 5.3 can be explained as follows:

1

The console handler supports a separate log level configuration property. This allows you to limit the log messages printed to the console while the global logging setting can be different (see Configuring Logging Levels). The default setting is WARNING.

2

Specifies the java.util.logging formatter class that the console handler class uses to format the log messages. The default setting is the java.util.logging.SimpleFormatter.

Example 5.4 shows code that configures the file handler.


The file handler also supports the configuration properties shown in Example 5.5.

Example 5.5. File Handler Configuration Properties

java.util.logging.FileHandler.pattern = %h/java%u.log 1
java.util.logging.FileHandler.limit = 50000 2
java.util.logging.FileHandler.count = 1 3
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter 4

The configuration properties shown in Example 5.5 can be explained as follows:

1

Specifies the location and pattern of the output file. The default setting is your home directory.

2

Specifies, in bytes, the maximum amount that the logger writes to any one file. The default setting is 50000. If you set it to zero, there is no limit on the amount that the logger writes to any one file.

3

Specifies how many output files to cycle through. The default setting is 1.

4

Specifies the java.util.logging formatter class that the file handler class uses to format the log messages. The default setting is the java.util.logging.XMLFormatter.

You can set the logging utility to output log messages to both the console and to a file by specifying the console handler and the file handler, separated by a comma, as shown in Example 5.6.