You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Arindam <ar...@gmail.com> on 2009/01/19 05:41:47 UTC
log4j and xlink
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.
--
Arindam Sharma
Undergraduate Student
Department of Computer Science and Engineering
Indian Institute of Technology, Kharagpur
Re: log4j and xlink
Posted by Arindam <ar...@gmail.com>.
On Tue, Jan 20, 2009 at 9:25 AM, Curt Arnold <ca...@apache.org> wrote:
>
> On Jan 19, 2009, at 7:05 PM, Arindam wrote:
>
> On Mon, Jan 19, 2009 at 11:52 PM, Curt Arnold <ca...@apache.org> wrote:
>>
>>>
>>> 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 ?
>>
>>
>> Thanks,
>> Arindam.
>>
>
>
> What version of log4j are you using? I could see that happening with
> earlier versions of log4j, but I don't think it would happen with log4j
> 1.2.15. The "dummy" protocol is definitely something originating in log4j,
> not Xerces. Xerces definitely can handle URL's relative to file: URL's.
>
>
Oh yes, works perfectly with log4j 1.2.15. Was using 1.2.11 earlier.
Thanks a lot.
Re: log4j and xlink
Posted by Curt Arnold <ca...@apache.org>.
On Jan 19, 2009, at 7:05 PM, Arindam wrote:
> On Mon, Jan 19, 2009 at 11:52 PM, Curt Arnold <ca...@apache.org>
> wrote:
>>
>> 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 ?
>
>
> Thanks,
> Arindam.
What version of log4j are you using? I could see that happening with
earlier versions of log4j, but I don't think it would happen with
log4j 1.2.15. The "dummy" protocol is definitely something
originating in log4j, not Xerces. Xerces definitely can handle URL's
relative to file: URL's.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: log4j and xlink
Posted by Arindam <ar...@gmail.com>.
On Mon, Jan 19, 2009 at 11:52 PM, Curt Arnold <ca...@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 ?
Thanks,
Arindam.
Re: log4j and xlink
Posted by Curt Arnold <ca...@apache.org>.
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).
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org