Enable ehcache debug in jboss

I’ve been trying to setup ehcache clustering in JBoss and unless there is a problem I’ve noticed there is little logging involved. So enabling logging should be a straightforward operation, I said. And it sure is if you bother to consider that the default ehcache distribution uses slf4j which is packed only with the jdk logger. So by default no matter how much you configure log4j no logging will be done. Of course after you add the log4j12 logger (by downloading the corresponding jar from slf4j distribution) it’s only a matter of doing something like this in the jboss-log4j.xml file:

<appender name="EHCACHE" class="org.jboss.logging.appender.RollingFileAppender">
                <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler" />
                <param name="File" value="${jboss.server.log.dir}/ehcache.log" />
                <param name="Append" value="true" />
                <param name="MaxFileSize" value="10MB" />
                <param name="MaxBackupIndex" value="10" />
                <param name="Threshold" value="TRACE" />
                <layout class="org.apache.log4j.PatternLayout">
                        <param name="ConversionPattern" value="%d %-5p [%c] %m%n" />
        <category name="net.sf.ehcache">
                <priority value="TRACE" />
                <appender-ref ref="EHCACHE" />

Applies to ehcache 2.4.* and jboss < 7.

Leave a Reply