Re: Logging Strategy/best practice



Just a quick tip - Log4J works differently in JBoss then elsewhere.
Typically you put log4.xml/properties in the root of your classpath, or
alternatively load it via a servlet with loadOnStartup. JBoss ignores
that practice - for better or worse.

To control logging with JBoss 4.0.1, I edit:

jboss/server/default/conf/log4j.xml

And have:

<appender name="CALLCENTREWEB_FILE"
class="org.apache.log4j.FileAppender">
<param name="File"
value="${jboss.server.home.dir}/log/call_centre_web.log" />
<param name="Append" value="true" />

<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd MMM yyy HH:mm:ss},
%-6p %C:%M:%L %m %n" />
</layout>
</appender>

<category name="com.hostedtelecom.callcentreweb">
<priority value="DEBUG" />
<appender-ref ref="CALLCENTREWEB_FILE" />
</category>

Hibernate and Spring have there own appenders. Such as (Not tested in
Jboss, just tomcat, but idea is the same):

log4j.category.org.springframework=WARN, console2, apacheOrg

log4j.category.net.sf.hibernate=WARN, console2, apacheOrg

You'll need to convert those to the xml format JBoss uses. Search the
JBoss group for details or post a question there.

HTH,
iksrazal
http://www.braziloutsource.com/

.