[ 
https://issues.apache.org/jira/browse/LOG4J2-204?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13627696#comment-13627696
 ] 

Remko Popma commented on LOG4J2-204:
------------------------------------

Ralph, I agree with your analysis, but would it not be better if the error 
message indicated this more clearly?

How about adding this constructor to 
org.apache.logging.slf4j.SLF4JLoggerContext:

    public SLF4JLoggerContext() {
        // LOG4J2-204 (improve error reporting when misconfigured)
        try {
            Class.forName("org.slf4j.helpers.Log4JLoggerFactory");
            throw new IllegalStateException("slf4j-impl jar is mutually 
exclusive with log4j-to-slf4j jar " +
                        "(the first routes calls from SLF4J to Log4j, the 
second from Log4j to SLF4J)");
        } catch (Throwable classNotFoundIsGood) {
        }
    }


This object is only created once, so there is almost no performance impact, and 
it may help people figure out what is going wrong.
(Maybe we can document this on the web site somewhere too, but this is more 
direct...)
                
> java.lang.NoClassDefFoundError: org/slf4j/spi/LocationAwareLogger
> -----------------------------------------------------------------
>
>                 Key: LOG4J2-204
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-204
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.0-beta4
>         Environment: Product Version: NetBeans IDE 7.3 (Build 201302132200)
> Java: 1.7.0_17; Java HotSpot(TM) 64-Bit Server VM 23.7-b01
> Runtime: Java(TM) SE Runtime Environment 1.7.0_17-b02
> System: Windows 7 version 6.1 running on amd64; Cp1250; pl_PL (nb)
> User directory: C:\Users\Wojtek\AppData\Roaming\NetBeans\7.3
> Cache directory: C:\Users\Wojtek\AppData\Local\NetBeans\Cache\7.3
>            Reporter: Wojciech Zaręba
>              Labels: newbie
>         Attachments: error.log
>
>
> Very simple source:
> package loggerimpl;
> import org.apache.logging.log4j.LogManager;
> import org.apache.logging.log4j.Logger;
> public class LoggerImpl {
>     private static Logger logg = 
> LogManager.getLogger(LoggerImpl.class.getName());
>     public static void main(String[] args) {
>         logg.info("Pierwsze info");
>         logg.debug("Drugi debug");
>         logg.warn("Trzeci warning");
>         logg.trace("Czwarty trace");
>         logg.error("Piąty ERROR");
>         logg.fatal("Szósty F A T A L");
>     }
> }
> produces error:
> 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 loggerimpl.LoggerImpl.<clinit>(LoggerImpl.java:11)
> Caused by: java.lang.ClassNotFoundException: org.slf4j.spi.LocationAwareLogger
>       at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
>       at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>       at java.security.AccessController.doPrivileged(Native Method)
>       at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>       at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
>       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
>       at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
>         .. 3 more
> Exception in thread "main" Java Result: 1
> I can't find in bins/sources org.slf4j.spi.LocationAwareLogger
> Regards
> Wojciech Zaręba

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to