On Jan 19, 2009, at 7:05 PM, Arindam wrote:

On Mon, Jan 19, 2009 at 11:52 PM, Curt Arnold <[email protected]> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to