Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.此内容没有您所选择的语言版本。
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
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
java.util.logging.ConsoleHandler.level = WARNING 1 java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter 2
java.util.logging.ConsoleHandler.level = WARNING 1
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter 2
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
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
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
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 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
.
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
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
.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
com.xyz.foo.level = SEVERE