Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I put the log4j.properties file?

People also ask

Where should log4j properties file be stored?

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 log4j log file location?

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.

Where does log4j properties file go in spring boot?

By default, Log4J 2 looks for a properties file with the name log4j2. properties in the classpath. In a Spring Boot application, the log4j2. properties file will typically be in the resources folder.


I know it's a bit late to answer this question, and maybe you already found the solution, but I'm posting the solution I found (after I googled a lot) so it may help a little:

  1. Put log4j.properties under WEB-INF\classes of the project as mentioned previously in this thread.
  2. Put log4j-xx.jar under WEB-INF\lib
  3. Test if log4j was loaded: add -Dlog4j.debug @ the end of your java options of tomcat

Hope this will help.

rgds


As already stated, log4j.properties should be in a directory included in the classpath, I want to add that in a mavenized project a good place can be src/main/resources/log4j.properties


You can specify config file location with VM argument -Dlog4j.configuration="file:/C:/workspace3/local/log4j.properties"


You have to put it in the root directory, that corresponds to your execution context.

Example:

    MyProject
       src
           MyClass.java
           log4j.properties

If you start executing from a different project, you need to have that file in the project used for starting the execution. For example, if a different project holds some JUnit tests, it needs to have also its log4j.properties file.


I suggest using log4j.xml instead of the log4j.properties. You have more options, get assistance from your IDE and so on...


For a Maven Based Project keep your log4j.properties in src/main/resources. Nothing else to do!


If you put log4j.properties inside src, you don't need to use the statement -

PropertyConfigurator.configure("log4j.properties");

It will be taken automatically as the properties file is in the classpath.


Try:

PropertyConfigurator.configure(getClass().getResource("/controlador/log4j.properties"));