logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arindam <arindam.bosc...@gmail.com>
Subject Re: log4j and xlink
Date Tue, 20 Jan 2009 01:05:42 GMT
On Mon, Jan 19, 2009 at 11:52 PM, Curt Arnold <carnold@apache.org> wrote:

> On Jan 18, 2009, at 10:41 PM, Arindam wrote:
>  Hi, I am faced with a problem. I have multiple java-modules which run as
>> daemons, and am configuring their log4j.xml configuration.
>> I would like the individual xml configuration files to pick up the stdout
>> /
>> email appenders from a core file, and have their own appenders along with
>> them.
>> I was thinking of using Xlink to do such a linking, but it seems Xlink is
>> not supported in log4j.
>> Is there a way to link appenders defined in another xml ? Except maybe
>> programmatically attach an appender ?
>> Thanks,
>> Arindam.
> You can use external entities which the XML parser will resolve before
> log4j see anything.  For example:
> <!DOCTYPE log4j:configuration [
> <!ENTITY common SYSTEM "common.xml">
> ]>
> <log4j:configuration>
>   <!--  common stuff -->
>    &common;
>   <!--  custom stuff -->
> </log4j:configuration>
> I believe earlier versions of log4j had problems with external entities
> (either they didn't work at all or you had to use absolute URL since the
> base URL was lost).

Thanks Curt, it works like a charm, the only caveat being I have to put the
external entity up as a HTTP URL publicly accessible.
Otherwise java.net.MalformedURLException: unknown protocol: dummy is thrown
for a local file.
Basically the internal xerces handler has code only to deal with http
protocols, and not anything else.
I tried using file://common.xml , but strangely that tries to do a ftp
access ...

This will satisfy my needs, but I would really like it to work without
running a webserver instance. Any ideas on it ?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message