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:

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


        <category name="net.sf.ehcache">
                <priority value="TRACE"></priority>
                <appender-ref ref="EHCACHE"></appender-ref>
        </category>

Applies to ehcache 2.4.* and jboss < 7.