{"action":"closed","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/4822","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/4822/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/4822/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/4822/events","html_url":"https://github.com/spring-projects/spring-boot/issues/4822","id":123308306,"number":4822,"title":"NPE in devtools when restarting an application that uses the Log4j2 API","user":{"login":"mrumpf","id":1191530,"avatar_url":"https://avatars.githubusercontent.com/u/1191530?v=3","gravatar_id":"","url":"https://api.github.com/users/mrumpf","html_url":"https://github.com/mrumpf","followers_url":"https://api.github.com/users/mrumpf/followers","following_url":"https://api.github.com/users/mrumpf/following{/other_user}","gists_url":"https://api.github.com/users/mrumpf/gists{/gist_id}","starred_url":"https://api.github.com/users/mrumpf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrumpf/subscriptions","organizations_url":"https://api.github.com/users/mrumpf/orgs","repos_url":"https://api.github.com/users/mrumpf/repos","events_url":"https://api.github.com/users/mrumpf/events{/privacy}","received_events_url":"https://api.github.com/users/mrumpf/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/spring-projects/spring-boot/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/spring-projects/spring-boot/milestones/50","html_url":"https://github.com/spring-projects/spring-boot/milestones/1.3.2","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/milestones/50/labels","id":1462925,"number":50,"title":"1.3.2","description":"","creator":{"login":"philwebb","id":519772,"avatar_url":"https://avatars.githubusercontent.com/u/519772?v=3","gravatar_id":"","url":"https://api.github.com/users/philwebb","html_url":"https://github.com/philwebb","followers_url":"https://api.github.com/users/philwebb/followers","following_url":"https://api.github.com/users/philwebb/following{/other_user}","gists_url":"https://api.github.com/users/philwebb/gists{/gist_id}","starred_url":"https://api.github.com/users/philwebb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philwebb/subscriptions","organizations_url":"https://api.github.com/users/philwebb/orgs","repos_url":"https://api.github.com/users/philwebb/repos","events_url":"https://api.github.com/users/philwebb/events{/privacy}","received_events_url":"https://api.github.com/users/philwebb/received_events","type":"User","site_admin":false},"open_issues":28,"closed_issues":9,"state":"open","created_at":"2015-12-16T10:13:54Z","updated_at":"2016-01-12T15:13:39Z","due_on":"2016-01-21T00:00:00Z","closed_at":null},"comments":3,"created_at":"2015-12-21T16:15:16Z","updated_at":"2016-01-12T15:13:39Z","closed_at":"2016-01-12T15:13:39Z","body":"When the application uses the Log4j2 API, the current implementation of the ```Log4j2RestartListener``` runs into a NPE when trying to make a private method accessible, which is not present:\r\n\r\n```\r\n2015-12-21 16:55:00.410 DEBUG 12620 --- [   File Watcher] o.s.boot.devtools.restart.Restarter\u001B: Restarting application\r\njava.lang.NullPointerException\r\n\tat org.springframework.util.ReflectionUtils.makeAccessible(ReflectionUtils.java:439)\r\n\tat org.springframework.boot.devtools.log4j2.Log4J2RestartListener.prepareLog4J2ForRestart(Log4J2RestartListener.java:51)\r\n\tat org.springframework.boot.devtools.log4j2.Log4J2RestartListener.beforeRestart(Log4J2RestartListener.java:43)\r\n\tat org.springframework.boot.devtools.restart.Restarter.beforeRestart(Restarter.java:331)\r\n\tat org.springframework.boot.devtools.restart.Restarter.access$200(Restarter.java:81)\r\n\tat org.springframework.boot.devtools.restart.Restarter$2.call(Restarter.java:253)\r\n\tat org.springframework.boot.devtools.restart.Restarter$2.call(Restarter.java:249)\r\n\tat org.springframework.boot.devtools.restart.Restarter$LeakSafeThread.run(Restarter.java:602)\r\n```\r\n\r\nThe application setup is to use logback as backend logger implementation and to redirect log4j2 to slf4j (via ```log4j-to-slf4j.jar```). In this case there is the class ```org.apache.logging.log4j.LogManager``` on the classpath (via ```log4j-api.jar```), but it seems as if the method ```shutdownCallbackRegistry``` is not available on the class ```SLF4JLoggerContextFactory```, which is generated by the ```getFactory``` method:\r\nhttps://github.com/apache/logging-log4j2/blob/master/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContextFactory.java\r\n\r\nThis causes all my services to suddenly stop (disappear from the Spring Boot Dashboard) when a change is detected and dependent applications are restarted.\r\n\r\nVersion 2.5 of the Log4j2 libs is used."}}