log4j LogManager.getLogger get's stuck in an infinite loop

别等时光非礼了梦想. 提交于 2019-12-11 06:06:11

问题


For some strange reason, I have a line of code that is getting stuck in an infinite loop. This is the line:

this.logger = LogManager.getLogger(getClass().getName());

A little context might be helpful:
I have a machine that stores all the code and java .class files. I access this machine through sshfs and work directly on the .java files through Eclipse.

If I login in the remote machine and execute my class, the code runs:

$ ssh remote-machine
$ cd /path/to/eclipse-project
$ export CLASSPATH="..." # A bunch of required libraries, including
                         # log4j-api-2.0-beta7.jar and log4j-core-2.0-beta7.jar
$ java path.to.MyClass
Welcome, please do stuff
>>>

If I use the sshfs file system mounted on my machine:

$ cd /mount-point/to/remote-machine
$ cd path/to/eclipse-project
$ export CLASSPATH="..."
$ java path.to.MyClass
<nothing happens>

I did, through Eclipse debugging, determine that LogManager#getLogger is the culprit. In fact, going a little deeper, I saw that there is a loop that starts with index=2 and only terminates when class==null, in ClassLoaderContextSelector.java:86.

来源:https://stackoverflow.com/questions/17838807/log4j-logmanager-getlogger-gets-stuck-in-an-infinite-loop

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!