Log4J + Ehcache Config Errors

414 views
Skip to first unread message

primesoftw...@gmail.com

unread,
May 8, 2016, 1:37:40 AM5/8/16
to ehcache-users
I am using Ehcache 3.0 and would like to have it work with Log4J. I have added all the necessary jars and set the Log4J config but keep getting the following:


log4j:WARN No appenders could be found for logger (org.ehcache.core.internal.service.ServiceLocator).
log4j:WARN Please initialize the log4j system properly.

Here is my log4j config:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="org.ehcache.core.internal.service.ServiceLocator" level="debug" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<Root level="debug">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
 
The logger is there and linked to the Console. Not sure why it can't find it.

Louis Jacomet

unread,
May 8, 2016, 2:32:33 AM5/8/16
to ehcache-users
Without project setup information, hard to give any advice.

Which libraries did you add? And which versions?
Where is that log4j config file?
Are you using gradle? something else?

--
You received this message because you are subscribed to the Google Groups "ehcache-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-user...@googlegroups.com.
To post to this group, send email to ehcach...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-users/a9e729c0-e8d2-40d3-9d38-ad3d5d5a8bce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

primesoftw...@gmail.com

unread,
May 8, 2016, 11:47:23 AM5/8/16
to ehcache-users
I added slf4j-log4j12-1.7.16, log4j-api-2.5, and log4j-core-2.5. I am using Gradle to build this and manage dependencies. In my Gradle config I have the following

run {
jvmArgs = ["-Dlog4j.configurationFile=file:/home/me/Programming/RESTServer/resources/config/log4j2.xml"]
}
 
 
I did notice something interesting. It looks like Gradle downloaded multiple version of log4j. Perhaps one is a dependency. Here is what I added to get log4j:


compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.5'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.5'

But I also noticed log4j:log4j:1.2.17 in my External Libraries. Is it possible ehcache added the older one and since I have not configured that one it thinks there is no config file?

Louis Jacomet

unread,
May 23, 2016, 8:58:53 AM5/23/16
to ehcache-users
Ehcache only has a dependency on org.slf4j:slf4j-api:1.7.7 as can be seen from http://repo1.maven.org/maven2/org/ehcache/ehcache/3.0.1/ehcache-3.0.1.pom

So this really looks like a logging setup issue for which I recommend http://www.slf4j.org/manual.html

Reply all
Reply to author
Forward
0 new messages