Reputation: 20571
I have a maven project and in class-path (resources
folder according to maven standard layout) I have several log4j.xml
files, like this:
-resources
-log4j.xml
-folder1
-log4j.xml
-folder2
-log4j.xml
How I can read log4j.xml
located at root? I think the following code doesn't guarantee that I will get log4j.xml
from root:
Thread.currentThread().getContextClassLoader().getResourceAsStream("log4j.xml")
Upvotes: 0
Views: 103
Reputation: 691635
Unless some other jar file is in the classpath of the current thread(s classloader, before yours, and also contains a log4j.xml file at the root, your code will do what you expect it to do.
To get the other one you would use "folder1/log4j.xml"
as path.
Upvotes: 2