2

I am having my log4j xml configuration file outside of the project. I am loading the xml configuration file by using absolute path as DOMConfigurator.configure("D:/E-Signature/ESignature logs/log4j_Properties_Xml/log4j-properties.xml");. Since I am going to convert my project to executable jar I have kept it outside of the project.

Is there any other efficient way to handle this without giving the absolute path.

Nidheesh
  • 4,390
  • 29
  • 87
  • 150

1 Answers1

-1

If your project is a maven project, you can put the log4j.properties in the src/main/resources folder so you don't need to give the absolute path and if it is a simple java project put it in the src folder it will work.

SparkOn
  • 8,806
  • 4
  • 29
  • 34
  • if i put inside the src folder it is not getting included in the executable jar. my project is simple java stand alone project. – Subash Suyambuthangam Jun 19 '14 at 05:56
  • under src make a sub-folder named resources and place it there and while getting the file in your code get it through with the following method getResourceAsStream() or getResource().Clean and Build will compile the code and embed the contents of the resources folder into the application’s .jar file please [refer](http://stackoverflow.com/questions/24298884/java-code-cannot-find-resource-file-after-build-and-clean-in-netbeans-ide/24299174#24299174) my comment in that and let me know the further issue – SparkOn Jun 19 '14 at 06:17
  • How can i load the xml configuration file using this approach. @M.Sharma – Subash Suyambuthangam Jun 19 '14 at 06:55
  • Load the xml configuration file what you mean by that?? – SparkOn Jun 19 '14 at 07:41