{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/4341","repository_url":"https://api.github.com/repos/spring-projects/spring-boot","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/4341/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/4341/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/4341/events","html_url":"https://github.com/spring-projects/spring-boot/issues/4341","id":114180997,"number":4341,"title":"log4j and logback conflict when running as packaged application","user":{"login":"scale9","id":15264208,"avatar_url":"https://avatars0.githubusercontent.com/u/15264208?v=4","gravatar_id":"","url":"https://api.github.com/users/scale9","html_url":"https://github.com/scale9","followers_url":"https://api.github.com/users/scale9/followers","following_url":"https://api.github.com/users/scale9/following{/other_user}","gists_url":"https://api.github.com/users/scale9/gists{/gist_id}","starred_url":"https://api.github.com/users/scale9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scale9/subscriptions","organizations_url":"https://api.github.com/users/scale9/orgs","repos_url":"https://api.github.com/users/scale9/repos","events_url":"https://api.github.com/users/scale9/events{/privacy}","received_events_url":"https://api.github.com/users/scale9/received_events","type":"User","site_admin":false},"labels":[{"id":16916894,"url":"https://api.github.com/repos/spring-projects/spring-boot/labels/status:%20invalid","name":"status: invalid","color":"fef2c0","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2015-10-30T01:38:44Z","updated_at":"2017-09-29T22:47:29Z","closed_at":"2015-10-30T07:03:03Z","author_association":"NONE","body":"When using **spring-boot-starter-log4j2**, the following exception is thrown while starting the application as a packaged application (`java -jar target/myproject-0.0.1-SNAPSHOT.jar`):\n\n```\nSLF4J: Class path contains multiple SLF4J bindings.\nSLF4J: Found binding in [jar:file:xxx/target/myproject-0.0.1-SNAPSHOT.jar!/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]\nSLF4J: Found binding in [jar:file:xxx/target/myproject-0.0.1-SNAPSHOT.jar!/lib/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]\nSLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.\nSLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]\njava.lang.reflect.InvocationTargetException\n    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n    at java.lang.reflect.Method.invoke(Method.java:497)\n    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)\n    at java.lang.Thread.run(Thread.java:745)\nCaused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.apache.logging.slf4j.Log4jLoggerFactory loaded from jar:file:xxx/target/myproject-0.0.1-SNAPSHOT.jar!/lib/log4j-slf4j-impl-2.4.1.jar!/). If you are using Weblogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml Object of class [org.apache.logging.slf4j.Log4jLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext\n```\n\nWhen running the application with Maven plugin (`mvn spring-boot:run`), it starts successfully, and I've noticed that the ordering of the classpath is different between `mvn spring-boot:run` and `java -jar` and a different binding is being picked up:\n\n```\nSLF4J: Class path contains multiple SLF4J bindings.\nSLF4J: Found binding in [jar:file:/Users/yang/.m2/repository/ch/qos/logback/logback-classic/1.1.3/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]\nSLF4J: Found binding in [jar:file:/Users/yang/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.3/log4j-slf4j-impl-2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]\nSLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.\nSLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]\n```\n\nThe exception is identical to #541, although I'm using Maven 3.2.1 to package the jar, and there's no issue with running the application with Maven directly as mentioned previously.\nRelevant dependencies:\n\n```\n<parent>\n    <groupId>org.springframework.boot</groupId>\n    <artifactId>spring-boot-starter-parent</artifactId>\n    <version>1.3.0.BUILD-SNAPSHOT</version>\n</parent>\n\n<dependency>\n    <groupId>org.springframework.boot</groupId>\n    <artifactId>spring-boot-starter-actuator</artifactId>\n    <exclusions>\n        <exclusion>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-logging</artifactId>\n        </exclusion>\n    </exclusions>\n</dependency>\n<dependency>\n    <groupId>org.springframework.boot</groupId>\n    <artifactId>spring-boot-starter-web</artifactId>\n    <exclusions>\n        <exclusion>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-logging</artifactId>\n        </exclusion>\n    </exclusions>\n</dependency>\n\n<dependency>\n    <groupId>org.springframework.boot</groupId>\n    <artifactId>spring-boot-starter-log4j2</artifactId>\n    <exclusions>\n        <exclusion>\n            <groupId>org.slf4j</groupId>\n            <artifactId>slf4j-log4j12</artifactId>\n        </exclusion>\n    </exclusions>\n</dependency>\n<dependency>\n    <groupId>org.springframework.boot</groupId>\n    <artifactId>spring-boot-starter-test</artifactId>\n    <scope>test</scope>\n    <exclusions>\n        <exclusion>\n            <groupId>org.springframework.boot</groupId>\n            <artifactId>spring-boot-starter-logging</artifactId>\n        </exclusion>\n    </exclusions>\n</dependency>\n```\n\nWe are using **Java 1.8.0_66**.\n"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/333256451","html_url":"https://github.com/spring-projects/spring-boot/issues/4341#issuecomment-333256451","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/4341","id":333256451,"user":{"login":"pozelim","id":11193638,"avatar_url":"https://avatars0.githubusercontent.com/u/11193638?v=4","gravatar_id":"","url":"https://api.github.com/users/pozelim","html_url":"https://github.com/pozelim","followers_url":"https://api.github.com/users/pozelim/followers","following_url":"https://api.github.com/users/pozelim/following{/other_user}","gists_url":"https://api.github.com/users/pozelim/gists{/gist_id}","starred_url":"https://api.github.com/users/pozelim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pozelim/subscriptions","organizations_url":"https://api.github.com/users/pozelim/orgs","repos_url":"https://api.github.com/users/pozelim/repos","events_url":"https://api.github.com/users/pozelim/events{/privacy}","received_events_url":"https://api.github.com/users/pozelim/received_events","type":"User","site_admin":false},"created_at":"2017-09-29T22:47:29Z","updated_at":"2017-09-29T22:47:29Z","author_association":"NONE","body":"@binnchx have you found a solution for that?"}}
{"actor":{"display_login":"pozelim"}}