Questo contenuto non è disponibile nella lingua selezionata.

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/.
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat