I added following configuration in my jboss AS'S CONFIG directory
Entry in jboss-log4j.xml file
<appender name="YYY" class="org.apache.log4j.FileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"></errorHandler>
<param name="Append" value="false"/>
<param name="File" value="${jboss.server.home.dir}/log/app1.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
</layout>
</appender>
<category name="com.XXX">
<priority value="INFO" />
<appender-ref ref="YYY"></appender-ref>
</category>
I have seen app1.log been created on JBoss start up.I do not have an app specific log4j.properties or log4j.xml file inside my application war file.All I wanted is classes from com.XXX should log to app1.log.But its not happening.
Cant I achieve it with out having a log4j.properties in my application war. My Jboss is configured in such a way that application specific log4j.properties should be override with jboss-log4j.xml file.
Any help appreciated
You can definitely do this. In
$JBOSS_HOME/server/$PROFILE/conf/jboss-log4j.xml
, make the following modifications:-You shouldn't even need to restart the JBoss instance. Please note $jboss.server.log.dir ($JBOSS_HOME/server/$PROFILE/log) is passed as a JVM argument in the run.sh or as a command line parameter to run.sh.
If you are not seeing any output then it probably is that your application does not have log4j instantiated correctly or your package name is different or you are hitting the wrong application or simply you are not hitting the log statements in the code execution. Make sure that your class has log4j instantiated correctly & under the correct package name. For instance:
In addition to the configuration you mentioned, you need to make sure your application war does not include any log4j.jar or commons-logging.jar files.