このコンテンツは選択した言語では利用できません。
17.3. Default logging configuration file
17.3.1. Overview of Logging Configuration
The default logging configuration file,
logging.properties
, is located in the InstallDir/etc
directory. It configures the Apache CXF loggers to print WARNING
level messages to the console. If this level of logging is suitable for your application, you do not have to make any changes to the file before using it. You can, however, change the level of detail in the log messages. For example, you can change whether log messages are sent to the console, to a file or to both. In addition, you can specify logging at the level of individual packages.
Note
This section discusses the configuration properties that appear in the default
logging.properties
file. There are, however, many other java.util.logging
configuration properties that you can set. For more information on the java.util.logging
API, see the java.util.logging
javadoc at: http://download.oracle.com/javase/1.5/docs/api/java/util/logging/package-summary.html.
17.3.2. Configuring Logging Output
Overview
The Java logging utility,
java.util.logging
, uses handler classes to output log messages. Table 17.1, “Java.util.logging Handler Classes” shows the handlers that are configured in the default logging.properties
file.
Handler Class | Outputs 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 Apache CXF environment.
Configuring the console handler
Example 17.2, “Configuring the Console Handler” shows the code for configuring the console logger.
Example 17.2. Configuring the Console Handler
handlers= java.util.logging.ConsoleHandler
The console handler also supports the configuration properties shown in Example 17.3, “Console Handler Properties”.
Example 17.3. Console Handler Properties
The configuration properties shown in Example 17.3, “Console Handler Properties” 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 Section 17.3.3, “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 thejava.util.logging.SimpleFormatter
.
Configuring the file handler
Example 17.4, “Configuring the File Handler” shows code that configures the file handler.
Example 17.4. Configuring the File Handler
handlers= java.util.logging.FileHandler
The file handler also supports the configuration properties shown in Example 17.5, “File Handler Configuration Properties”.
Example 17.5. File Handler Configuration Properties
The configuration properties shown in Example 17.5, “File Handler Configuration Properties” 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 thejava.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 17.6, “Configuring Both Console Logging and File Logging”.
Example 17.6. Configuring Both Console Logging and File Logging
handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
17.3.3. Configuring Logging Levels
Logging levels
The
java.util.logging
framework supports the following levels of logging, from the least verbose to the most verbose:
SEVERE
WARNING
INFO
CONFIG
FINE
FINER
FINEST
Configuring the global logging level
To configure the types of event that are logged across all loggers, configure the global logging level as shown in Example 17.7, “Configuring Global Logging Levels”.
Example 17.7. Configuring Global Logging Levels
.level= WARNING
Configuring logging at an individual package level
The
java.util.logging
framework supports configuring logging at the level of an individual package. For example, the line of code shown in Example 17.8, “Configuring Logging at the Package Level” configures logging at a SEVERE
level on classes in the com.xyz.foo package.
Example 17.8. Configuring Logging at the Package Level
com.xyz.foo.level = SEVERE