Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the correct location to put Log4j.properties in an Eclipse project?

Where in my Eclipse project should I add the log4j.properties file so that it will work as intended?

like image 854
Srinivas Reddy Avatar asked Feb 22 '11 17:02

Srinivas Reddy


People also ask

Where should log4j properties be placed?

The file is named log4j. properties and is located in the $DGRAPH_HOME/dgraph-hdfs-agent/lib directory. The file defines the ROLLINGFILE appenders for the root logger and also sets the log level for the file. The level of the root logger is defined as INFO and attaches the ROLLINGFILE appender to it.

Where is the log4j located?

The Log4j logging settings are stored in the file app_data /conf/server/log4j. properties, where app_data is the application data folder. You can edit this file directly on the server or open it by clicking Settings > Logging.


2 Answers

you can add it any where you want, when you run your project, configure the classpath and add the location of the log4j.properties files by clicking on: Run->Run Configuration -> [classpath tab] -> click on user Entries -> Advanced -> Select Add Folder -> select the location of your log4j.properties file

and then -> OK -> run

and it should get loaded

like image 145
Charbel Avatar answered Sep 18 '22 06:09

Charbel


The safest way IMO is to point at the file in your run/debug config

-Dlog4j.configuration=file:mylogging.properties 

! Be aware: when using the eclipse launch configurations the specification of the file: protocol is mandatory.

In this way the logger will not catch any logging.properties that come before in the classpath nor the default one in the JDK.

Also, consider actually use the log4j.xml which has a richer expression syntax and will allow more things (log4j.xml tahe precedence over log4j.properties.

like image 32
Alain Pannetier Avatar answered Sep 22 '22 06:09

Alain Pannetier