You cannot have both log4j-slf4j-impl and log4j-to-slf4j. The first routes all 
calls from the SLF4J API to the Log4j 2 API. The second routes all calls from 
the Log4j 2 API to SLF4J.  This is creating the circularity.  You should only 
include the jars you need based on what you want to do.  For example, if you 
are coding to the Log4j 2 API you only need log4j-api and log4j-core.  If you 
want SLF4J calls to go to Log4j then add log4j-slf4j-impl.

Ralph

On Mar 24, 2013, at 11:35 AM, wangke wrote:

> Here it 
> is:log4j-1.2-api-2.0-beta4log4j-api-2.0-beta4log4j-core-2.0-beta4-testslog4j-core-2.0-beta4log4j-flume-ng-2.0-beta4log4j-jcl-2.0-beta4log4j-slf4j-impl-2.0-beta4log4j-to-slf4j-2.0-beta4slf4j-api-1.7.2slf4j-ext-1.7.2
> 
>> Subject: Re: Problems with log4j 2
>> From: ralph.go...@dslextreme.com
>> Date: Sun, 24 Mar 2013 08:27:24 -0700
>> To: log4j-user@logging.apache.org
>> 
>> Can you provide the list of jars you have on your classpath?
>> 
>> Ralph
>> 
>> On Mar 23, 2013, at 11:08 PM, wangke wrote:
>> 
>>> Hi all:
>>> I am trying to get this simple example working, I included all the jars in 
>>> apache-log4j-2.0-beta4-bin
>>> 
>>> import org.apache.logging.log4j.LogManager;import 
>>> org.apache.logging.log4j.Logger; public class HelloWorld {    private 
>>> static Logger logger = LogManager.getLogger("HelloWorld");    public static 
>>> void main(String[] args) {        logger.info("Hello, World!");    }}
>>> Here is the exception I am getting in eclipse:Exception in thread "main" 
>>> java.lang.NoClassDefFoundError: org/slf4j/spi/LocationAwareLogger
>>>     at 
>>> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
>>>     at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:342)
>>>     at test.HelloWorld.<clinit>(HelloWorld.java:7)
>>> Caused by: java.lang.ClassNotFoundException: 
>>> org.slf4j.spi.LocationAwareLogger
>>>     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
>>>     at java.security.AccessController.doPrivileged(Native Method)
>>>     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
>>>     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>>>     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>>>     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>>>     ... 3 more
>>> Then I've added slf4j-api-1.7.2.jar. I've still couldn't get it working 
>>> with what looks like a non-terminated recursive loop eventually overflowing 
>>> my stack.Exception in thread "main" java.lang.StackOverflowError
>>>     at java.lang.Throwable.getStackTraceDepth(Native Method)
>>>     at java.lang.Throwable.getOurStackTrace(Throwable.java:588)
>>>     at java.lang.Throwable.getStackTrace(Throwable.java:582)
>>>     at 
>>> org.slf4j.helpers.Log4JLoggerFactory.getContext(Log4JLoggerFactory.java:75)
>>>     at 
>>> org.slf4j.helpers.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:45)
>>>     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>>>     at 
>>> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
>>>     at 
>>> org.slf4j.helpers.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:52)
>>>     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>>>     at 
>>> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
>>>     at 
>>> org.slf4j.helpers.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:52)
>>>     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>>>     at 
>>> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
>>>     at 
>>> org.slf4j.helpers.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:52)
>>>     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>>>     at 
>>> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
>>>     at 
>>> org.slf4j.helpers.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:52)
>>>     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>>>     at 
>>> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
>>>     at 
>>> org.slf4j.helpers.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:52)
>>>     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>>>     at 
>>> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
>>>     at 
>>> org.slf4j.helpers.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:52)
>>>     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>>>     at 
>>> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
>>>     at 
>>> org.slf4j.helpers.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:52)
>>>     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>>>     at 
>>> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
>>>     at 
>>> org.slf4j.helpers.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:52)
>>>     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>>>     at 
>>> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
>>>     at 
>>> org.slf4j.helpers.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:52)
>>>     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
>>>     at 
>>> org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
>>>     at 
>>> org.slf4j.helpers.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:52)
>>>     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270) 
>>> Can anybody pls help? Thanks a lot.
>>> Ke                                                                          
>>>                                                                             
>>>       
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>> 
>                                         


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to