tags:

views:

114

answers:

1

Hi, I am using log4j with Java and wanted to configure my XML-Config-File (I need to use XML for the ErrorHandler), so that some Properties in the XML (like the Backup-Value for the RollingFileAppender) could be changed within the DOMConfigurator of the log4j-API. This class also got the subst()-method, which should substitute the chosen values, but I really don´t know how to handle it.

If their is no way changing the config with the DOMConfigurator, which else possibilities did I got to easily correct values in an ambiguous XML-File (So to say, because the XML-Tags are not unique or only their Tag-names, which are values itself)? My XML is kind of static or hand-written.

A: 

Why can't you fix the original XML file on the disk?

If for some reason that's not possible, I would rather try altering the configuration directly via Logger, after the config file has been loaded.

Péter Török
Thank you. It is possible to directly fix the XML, but it´s for a Costumer and I wanted, that he can set some Logging-Properties using the better readable Java-Properties instead of digging through more complicated XML.And setting the different properties via the Logger-API came also in my mind, but I don´t like this way of hard-coding a property-reference, so it might be a solution, but I kind of looking for something better/more flexible.
@rdogpink, I see. Why can't you use a property file instead of XML?
Péter Török
@ Péter: for incomprehensible reasons, log4j won´t support the Property-solution any more, so all the new Appendertypes like the AsyncAppender or the FallbackErrorhandler don´t work with Properties, so iam forced to use XML. I neither like it, too ;)
@rdogpink, hmmm... what version you are using? Could it be an option to switch back to an earlier version? I am using 1.2.14 and it works fine with properties.
Péter Török
@Péter: I´m using 1.2.16. It could be an option, and I guess, i´ll try it, if we couldn´t find a better solution. Are you sure, FallbackErrorHandler is also working with properties? Because using e.g. AsyncAppender doesn´t work with properties.
@rdogpink, I admit I've never used those, so I can't tell :-(
Péter Török
Not so bad, but can anybody at least say me, whether subst() is useful for my cases or how else it could be done?