We have deployed two EARs both with the same package file structure. Is it possible for Wildfly to log info to two separate log files whereby each EAR has its own logging information? If so, how do we configure this in the config file?
1 Answers
3
votes
Yes it is possible for you to Log information on separate files in Wildlfy. For this you will need to define multiple Logging Profiles on your wildfly configuration file.
Create New Logger Profile either Using Jboss CLI or Directly Updating the standalone.xml file.
Open your standalone.xml file and update the following section,
<subsystem xmlns="urn:jboss:domain:logging:3.0">
And Update the section to look like,
<logging-profiles>
<logging-profile name="accounts-app-profile">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.arjuna">
<level name="WARN"/>
</logger>
<logger category="org.jboss.as.config">
<level name="DEBUG"/>
</logger>
<logger category="sun.rmi">
<level name="WARN"/>
</logger>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
</logging-profile>
<logging-profile name="another-profile">
<!--Another Configuration Detail !-->
</logging-profile>
</logging-profiles>
Now Update your application[EAR's] MANIFEST.MF file to point your logging profile as needed,
Manifest-Version: 1.0
Logging-Profile: first-profile
Please follow the following link for quick reference : http://www.mastertheboss.com/jboss-server/jboss-log/using-a-logger-for-a-specific-application.
I have copied my standalone.xml configuration so you might need to change it as needed on your end.