此内容没有您所选择的语言版本。
17.2. Simple Example of Using Logging
Changing the log levels and output destination 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
To change the log level and output destination of the log messages in the wsdl_first sample application, complete the following steps:
- Run the sample server as described in the Running the demo using java section of the
README.txtfile in theInstallDir/samples/wsdl_firstdirectory. Note that the server start command specifies the defaultlogging.propertiesfile, as follows:Expand Platform Command Windows start java -Djava.util.logging.config.file=%CXF_HOME%\etc\logging.properties demo.hw.server.ServerUNIX java -Djava.util.logging.config.file=$CXF_HOME/etc/logging.properties demo.hw.server.Server &The defaultlogging.propertiesfile is located in theInstallDir/etcdirectory. It configures the Apache CXF loggers to printWARNINGlevel log messages to the console. As a result, you see very little printed to the console. - Stop the server as described in the
README.txtfile. - Make a copy of the default
logging.propertiesfile, name itmylogging.propertiesfile, and save it in the same directory as the defaultlogging.propertiesfile. - Change the global logging level and the console logging levels in your
mylogging.propertiesfile toINFOby editing the following lines of configuration:.level= INFO java.util.logging.ConsoleHandler.level = INFO
.level= INFO java.util.logging.ConsoleHandler.level = INFOCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Restart the server using the following command:
Expand Platform Command Windows start java -Djava.util.logging.config.file=%CXF_HOME%\etc\mylogging.properties demo.hw.server.ServerUNIX java -Djava.util.logging.config.file=$CXF_HOME/etc/mylogging.properties demo.hw.server.Server &Because you configured the global logging and the console logger to log messages of levelINFO, you see a lot more log messages printed to the console.