Red Hat DocumentationFuse ESBToggle FramesPrintFeedback

Configuring Logging Output

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

Table 20. Java.util.logging Handler Classes

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

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.

Configuring the console handler

Example 34 shows the code for configuring the console logger.

Example 34. Configuring the Console Handler

handlers= java.util.logging.ConsoleHandler

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

Example 35. 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 35 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.

Configuring the file handler

Example 36 shows code that configures the file handler.

Example 36. Configuring the File Handler

handlers= java.util.logging.FileHandler

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

Example 37. 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 37 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.

Configuring both the console handler and the file handler

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 38.

Example 38. Configuring Both Console Logging and File Logging

handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler

Comments powered by Disqus