Red Hat Training

A Red Hat training course is available for Red Hat JBoss Enterprise Application Platform

5.3. Per-deployment Logging

5.3.1. About Per-deployment Logging

Per-deployment logging allows a developer to configure in advance the logging configuration for their application. When the application is deployed, logging begins according to the defined configuration. The log files created through this configuration contain information only about the behavior of the application.
This approach has advantages and disadvantages over using system-wide logging. An advantage is that the administrator of the JBoss EAP instance does not need to configure logging. A disadvantage is that the per-deployment logging configuration is read only on startup and so cannot be changed at runtime.

5.3.2. Add Per-deployment Logging to an Application

To configure per-deployment logging, add the logging configuration file into the deployment. This configuration file is recommended because it can be used with any logging facade as the JBoss Log Manager is the underlying log manager used.
If you are using Simple Logging Facade for Java (SLF4J) or Apache log4j, the configuration file is suitable. If you are using Apache log4j appenders then the configuration file is required. The configuration file is supported only for legacy deployments.

Procedure 5.2. Add Configuration File to the Application

  • The directory into which the configuration file is added depends on the deployment method: EAR, WAR or JAR.

    • EAR deployment

      Copy the logging configuration file to the META-INF directory.
    • WAR or JAR deployment

      Copy the logging configuration file to either the META-INF or WEB-INF/classes directory.

5.3.3. Example File

# Additional loggers to configure (the root logger is always configured)
# Root logger configuration
# A handler configuration
# The formatter to use
formatter.PATTERN.pattern=%d %-5p %c: %m%n