Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting log4j.properties to log4j.xml [duplicate]

I couldn't find anywhere how to specify constants in log4j.xml. For example, I have this constant in my log4j.properties:

#Log directory
dal.log.dir=/var/log/pojodal/
# Log filename
dal.log.file=pojodal.log

And I use these constants as follows, in other parts of the properties file:

log4j.appender.DRFA1.File=${dal.log.dir}/${dal.log.file}

How to achieve the same behavior in log4j.xml?

like image 787
Hari Menon Avatar asked Dec 21 '22 08:12

Hari Menon


1 Answers

You can convert your complete log4j.properties using this online service, where you can paste your log4j.properties, press convert and copy your new log4j.xml:

http://log4j-props2xml.appspot.com/

If that webapp is offline ... you can also start it in your own servlet container ... you find downloads and sources here:

https://github.com/jroyals/log4j-properties-converter/

Use of variables in log4j.xml:

This is explained in an answer to another question ... using XML internal entities here and using Java System Properties here.

like image 109
Jörg Avatar answered Dec 28 '22 06:12

Jörg