where to put config.properties and log4j.xml in Eclipse

14,081

Solution 1

Place the log4j.xml on src/main/resources in eclipse. It should work.

Solution 2

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.

Share:
14,081
mitchmcc
Author by

mitchmcc

Updated on June 04, 2022

Comments

  • mitchmcc
    mitchmcc almost 2 years

    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