Anand Kadhi
Anand Kadhi

Reputation: 1878

How to separate application Logs in JBoss 7.0 using standalone.xml

I am using Jboss-7.0 and want to separate application logs based on War Files i.e I have war1 and war2 so based on that separate log files should be generated like war1.log and war2.log. The existing logging configuration is in standalone.xml. I have read this Link which is given by Jboss but the configuration they given is in jboss-log4j.xml file and not standalone.xml logging module changes.

Can someone please suggest with the changes required to separate log files per War in jboss-7.0

Upvotes: 2

Views: 4297

Answers (2)

Abhijit Humbe
Abhijit Humbe

Reputation: 1631

You can try with logging-profile. In standalone.xml define logging profile like as:

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

<logging-profiles>
    <logging-profile name="myLoggingProfile">
        <file-handler name="myHandler">
            <level name="ALL"/>
            <file relative-to="jboss.server.log.dir" path="myapp.log"/>
        </file-handler>
        <root-logger>
            <handlers>
                <handler name="myHandler"/>
            </handlers>
        </root-logger>
    </logging-profile>
</logging-profiles>

In MANIFEST.MF of application define name of the logging profile.

Logging-Profile: myLoggingProfile

Define different logging profile for each application, with this approach you should be able to generate separate logging for each war file.

Upvotes: 1

Abhijit Humbe
Abhijit Humbe

Reputation: 1631

To configure application logging you have to create appender which will capture logging for application class files based on package.

<periodic-rotating-file-handler name="myapp-handler" 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="myapp.log"/>
  <suffix value=".yyyy-MM-dd"/>
  <append value="true"/>
</periodic-rotating-file-handler>

<logger category="com.example.myapp" use-parent-handlers="false">
  <handlers>
    <handler name="myapp-handler"/>
  </handlers>
  <level name="DEBUG"/>
</logger>

If both war files have same packages then its not possible to configure separate log files.

Upvotes: 2

Related Questions