Configuring a JBoss Handler which writes in a distinct file logs for a package
This article shows how to configure a JBoss Logging Handler for a specific package (category) to be written in a separate log file.
Sometimes you need to add verbosity to a specific JBoss/WildFly package but you don’t want to mix it with the application server’s logs. So, in order to do that, you need to perform the following steps:
- Define a Handler which points to a file path. In most cases, the Periodic Rotating File Handler is the best choice
- Define a Logger, which contains the package (“category”) to be traced and the level of verbosity
<periodic-rotating-file-handler name="JTA-LOG" autoflush="true">
<file relative-to="jboss.server.log.dir" path="${jboss.node.name}_jta.log"/>
<rotate-size value="20000"/>
<max-backup-index value="3"/>
<suffix value=".yyyy-MM-dd"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.arjuna.ats.jta" use-parent-handlers="false">
<level name="TRACE"/>
<handlers>
<handler name="JTA-LOG"/>
</handlers>
</logger>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="JTA-LOG"/>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
In this example configuration, we have defined a Perodic Rotating File Handler writing a file named ${jboss.node.name}_jta.log in the standard log dir. This Handler traces the package “com.arjuna.ats.jta” and it is added to the roo-logger. This will help you to keep the logs for a specific package in a separate log file.
Recommended Articles
Configure WildFly's Periodic File Handler with Advanced Settings and Rotations
Learn how to configure the Periodic File Handler in WildFly for efficient log management. #WildFly #JavaLogging #CloudNative
Enable Logs Compression in WildFly Using Periodic Rotating File Handler and Log4j2
Learn how to compress logs in WildFly using the Periodic Rotating File Handler or Log4j2. #WildFly #JavaLogging #LogCompression
Inspection and Management of WildFly Logs via Command Line Interface - A Comprehensive Guide
Learn how to inspect WildFly logs using CLI with detailed examples and parameters for efficient log management.
Discover Where JBoss EAP/WildFly Logs Are Located: Standalone vs Domain Mode
Learn where to find and view logs in JBoss EAP/WildFly, whether running in standalone or domain mode.