I need to use custom filters, so I need to convert some long log4j.properties files to log4j.xml.
Is anyone aware of a tool to do this, or willing to contribute one they have used? Searching has thus far turned up no such tool.
I need to use custom filters, so I need to convert some long log4j.properties files to log4j.xml.
Is anyone aware of a tool to do this, or willing to contribute one they have used? Searching has thus far turned up no such tool.
Here is something that may help you. Ceki Gülcü, the creator of log4j, started another logger project named logback, and he provides an online translator for log4j.properties files to xml config files for logback. It looks like the configuration file schemas of log4j.xml and logback.xml are pretty close.
At least it should produce something that can easily be converted to the log4j.xml format.
For your convenience: here's a sample log4j.properties file from the log4j documentation. Just paste it into the translator and check the output:
I needed to do this as well, but couldn't find a tool. Migrating by hand dozens of log4j.properties was not a palatable option. So, I bashed together a tool that can do it and released it for others to use.
http://code.google.com/p/log4j-properties-converter/
It's a bit rough but did the trick for the log4j properties I gave it, so any problems log them on the issue tracker. Hope you find it useful.
Recently used https://github.com/balent/Log4j-Convert-Configuration to convert a log4j.xml file to a log4j.properties file (an ancient jar I had to use was explicitly looking for log4j.properties). The configuration allows going both ways: xml to properties OR properties to xml.
Download the binary build from https://github.com/balent/Log4j-Convert-Configuration/blob/master/binaries/full-with-dependencies/log4j-convert-full.jar and then just type:
Leaving this on here for future me to find.
Presumably you must have a lot of properties files you need to convert. When I wanted to switch to xml (many years ago) I couldn't find much documentation. I did find sample xml files in the log4j distribution which were very useful.