Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuration path of Log4j2

I am trying to adopt Log4j2 to my project. Since my Java Application is packeted in a JAR file. I don't want "log4j2.xml" configuration packaged inside of JAR file. I am trying to learn how configuration file works from "http://logging.apache.org/log4j/2.x/manual/configuration.html"

But seems there is no clear instruction regarding altering the configuration file path of the Log4j2.

After googling about this topic I found something like "Referencing log4j config file within executable JAR" Referencing log4j config file within executable JAR, But this solution is not available any more according to "http://logging.apache.org/log4j/2.x/manual/migration.html" (if I understand it correctly).

So I am wondering if someone have any idea about this issue.

Thanks

like image 900
user454083 Avatar asked Dec 18 '12 15:12

user454083


People also ask

Where is log4j configuration file located?

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.

Where is log4j2 installed?

Log4j 2. x is hosted in the Apache Software Foundation's subversion repository. Details on obtaining the most current source code can be found at Log4j Source Repository.

What is configuration status in log4j2?

Configuration: the root element of a log4j2 configuration file; the status attribute represents the level at which internal log4j events should be logged. Appenders: this element contains a list of appenders; in our example, an appender corresponding to the System console is defined.


1 Answers

You can set the system property to specify the configuration path. set the

"-Dlog4j.configurationFile="D:\learning\blog\20130115\config\LogConfig.xml" 

in VM arguments. replace

"D:\learning\blog\20130115\config\LogConfig.xml"

to your configuration path.

like image 146
Elar Avatar answered Oct 30 '22 20:10

Elar