Loading...

Configure separate log messages in JBoss

:heavy_exclamation_mark: This post is older than a year. Consider some information might not be accurate anymore. :heavy_exclamation_mark:

To configure JBoss to log certain messages of log category (class) is a simple way. This post illustrates two ways to achieve it.

Adjust configuration file

Editing the configuration file, e.g. standalone.xml for standalone mode, needs the JBoss instance not to be running.

To log messages to another file, go to subsystem logging.

<profile>
  <subsystem xmlns="urn:jboss:domain:logging:1.2">
..
</profile>

Add logger definition and binding within above section

<periodic-rotating-file-handler name="MESSAGE_LOG" autoflush="true">
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
    </formatter>
    <file relative-to="jboss.server.log.dir" path="message.log"/>
    <suffix value=".yyyy-MM-dd"/>
    <append value="true"/>
</periodic-rotating-file-handler>
<!-- bind log category to above logger -->
<logger category="net.cinhtau.adapter">
    <level name="DEBUG"/>
    <handlers>
        <handler name="MESSAGE_LOG"/>
    </handlers>
</logger>

Logger configuration as CLI script

Configure the JBoss from CLI, needs a running JBoss instance.

Add logger via CLI

/subsystem=logging/periodic-rotating-file-handler=MESSAGE_LOG:add(
		file={
		  "path"=>"message.log",
		  "relative-to"=>"jboss.server.log.dir"
		},
		suffix=".yyyy-MM-dd",
		append="true",
		formatter="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
		autoflush="true")
/subsystem=logging/logger=net.cinhtau.adapter:add(level=DEBUG, use-parent-handlers=false)
/subsystem=logging/logger=net.cinhtau.adapter:assign-handler(name="MESSAGE_LOG")

Check the folder log for your separate log file. For further details read for instance

Please remember the terms for blog comments.