Reputation: 379
When I first developed my Java app, I ended up with my config.properties and log4j.xml files in the 'src' directory. This worked fine running in Eclipse, but now I am trying to deploy to a Linux server.
When I deploy, I take the exported app jar file and explode it, but it of course does not have the 'src' directory.
When I move the two config files back to the root of the app, log4j is complaining that it cannot find the log4j.xml file.
I have tried to set the Run/Debug classpath as noted in several posts, but the Classpath tab already appears to show the app's main directory there.
What I need is to understand how I should lay out things like these two configuration files in Eclipse, so that when I export to a jar for deployment they are still visible.
Thanks,
Mitch
Upvotes: 3
Views: 15124
Reputation: 31
Place the log4j.xml on src/main/resources in eclipse. It should work.
Upvotes: 3
Reputation: 11
You have to add a line.
Log4jConfigurer.initLogging("SpringTest/src/log4JTest/log4j.xml");
to inform log4J that from here it should pick all custom info.
Upvotes: 1
Reputation: 7858
maybe configuring it as "classpath:log4j.xml" in your applicationContext.xml is enough, or, if it is not what you really want I suggest you to take a look about how to set it up using the approach of a Log4jDirectConfigurer
.
Upvotes: 0
Reputation: 8598
If you have placed your log4j.xml
or log4j.properties
file in your src
folder then it should work fine for the exported jar file as well. You could have a look this post which is similar.
Upvotes: 0