此内容没有您所选择的语言版本。

Chapter 6. Logging


Logging is the most important tool to troubleshoot errors and monitor the status of the components of the Platform. log4j provides a familiar, flexible framework, familiar to Java developers.
Section 6.1, “Logging Defaults” contains information about customizing the default logging behavior for the Platform. See Section 6.2, “Component-Specific Logging” for additional customization. Appendix C, Logging Information and Recipes provides some logging recipes, which you can customize to your needs.

6.1. Logging Defaults

The log4j configuration is loaded from the <JBOSS_HOME>/server/<PROFILE>/conf/jboss-log4j.xml deployment descriptor. log4j uses appenders to control its logging behavior. An appender is a directive for where to log information, and how to do it. The jboss-log4j.xml file contains many sample appenders, including FILE, CONSOLE, and SMTP.
Expand
Table 6.1. Common log4j Configuration Directives
Configuration Option Description
appender
The main appender. Gives the name and the implementing class.
errorHandler
Delegates an external class to handle exceptions passed to the logger, especially if the appender cannot write the log for some reason.
param
Options specific to the type of appender. In this instance, the <param> is the name of the file that stores the logs for the FILE appender.
layout
Controls the logging format. Tweak this to work with your log-parsing software of choice.

Example 6.1. Sample Appender

<appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
  <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
  <param name="File" value="${jboss.server.log.dir}/server.log"/>
  <param name="Append" value="true"/>
  <!-- In AS 5.0.x the server log threshold was set by a system property.
		 In 5.1 and later, the system property sets the priority on the root
		 logger (see <root/> below)
		 <param name="Threshold" value="${jboss.server.log.threshold}"/> -->
 
  <!-- Rollover at midnight each day -->
  <param name="DatePattern" value="'.'yyyy-MM-dd"/>
  <layout class="org.apache.log4j.PatternLayout">
	 <!-- The default pattern: Date Priority [Category] (Thread) Message\n -->
	 <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
  </layout>
</appender>
Copy to Clipboard Toggle word wrap
For more information on configuring log4j, see http://logging.apache.org/log4j/1.2/.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat