Re: Slightly OT: log4j - generic log4j.dtd

2009-05-01 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Gregor,

On 4/30/2009 11:43 AM, Gregor Schneider wrote:
> 
> 

Oh, one more thing: couldn't you just turn off XML validation and
completely remove log4j.dtd? Are you sure it's even being used? You
might be getting all hot and bothered over nothing ;)

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkn7Nk0ACgkQ9CaO5/Lv0PCq2gCeJv0lboB6i8wloDp7wFx0MtoJ
EnMAoJ40paKIqup3EAKccLMGKNhstybC
=HfBw
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Slightly OT: log4j - generic log4j.dtd

2009-05-01 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Gregor,

On 4/30/2009 11:43 AM, Gregor Schneider wrote:
> 
> 

Is there a PUBLIC definition, too? IIRC, most XML parsers can use the
PUBLIC part to look up the DTD in their cache, as Peter suggests. I have
no idea how to prime the cache, though.

> Because every bloody servlet needs it's very own log4j.dtd together
> with it's log4j.xml, which is why I'm looking for a smarter solution.

Did you mean every webapp or every servlet? I suspect the former.

> However, with log4j.dtd things are slightly different since it's
> always a file with the same content and I really dislike redundancies.

How about using a fully-qualified SYSTEM identifier? It could be local
(using a file: URL) or remote (http:)?

> So my idea was to use ${CATALINA_HOME}, pass this via "-Dlog4j.dtd as
> a Java-property to Tomcat and evaluate this property within log4j.xml,
> however, that does not seem to work:

While this sounds like a great idea, I believe neither log4j nor your
XML parser will choose to auto-replace ${foo} with the result of
System.getProperty("foo"). I'd think you'd have to do that yourself.

> log4j:ERROR Could not parse url
> [file:/home/tomcat/www/common/classes/log4j.xml].
> java.net.MalformedURLException: no protocol: ${log4j.dtd}
> at java.net.URL.(URL.java:567)
> at java.net.URL.(URL.java:464)

Another Gregor suggested that the replacement happens but the file: URL
is not recognized. Both assertions are false. The replacement obviously
did *not* happen.

> I do [know] that I can pass a URL, so basically some thing like
> 
> http://localhost/mylog4jconf/log4j.dtd";>
> 
> should work, but I don't like the idea that I have some directory just
> containg some configuration-files which is accessible via http.

Gotcha. It's also kinda silly to fetch a remote file unless it's
absolutely necessary.

> Server version: Apache Tomcat/5.5.17

Gasp!

> Architecture:   i386

Really? Not i686? Hm...

I'll toss a suggestion out there that I use all the time: ant. I use ant
for WAR building and local deployment (i.e. not using the 'manager'
app), and I use the  tool along with replacements enabled. I even
use it for log4j (in order to target my log files into
${CATALINA_BASE}/logs). Here's what I do:

log4j.properties (haven't bothered to use XML yet) contains this line:

log4j.appender.A1.file = @app-log-dir@/log4j.log

I use ant to replace @app-log-dir@ with my actual log directory like this:

.. lots of other filters ...


  


  
  


  


This results in copying log4j.properties to my build/classes directory
(which ultimately turns into WEB-INF/classes) and applying a string
replacement to replace the text "@app-log-dir@" (the @ symbols are part
of the replacement mechanism and aren't mentioned in the build.xml file)
to replace it with the value of the ${app.log.dir} property which, I
promise, points to "${CATALINA_BASE}/logs".

I'm not sure if this will fit into your deployment model, but it works
exceedingly well for ours.

- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkn7NgYACgkQ9CaO5/Lv0PDrnwCfVqIdroTP3z70CcJnXgMrHMJx
jPoAn0IRPI+FYx/k3gzQjpfjt3dAKmn7
=1CEp
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Slightly OT: log4j - generic log4j.dtd

2009-05-01 Thread André Warnier

Gregor Schneider wrote:

since there's no such such as $CATALINA_HOME/common in
Tomcat 6.

You could always create one..

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Slightly OT: log4j - generic log4j.dtd

2009-05-01 Thread Gregor Schneider
Thing is, that we have multiple boxes (Debian) running with multiple
hosters, so every layout of those boxes is different (i.e. one has
Tomcat in /var/lib, the other one in /usr/local, next one in
/home/apps/tomcat).

Since *some* of our servlets (i.e. our own SSO-mechanism) are runnung
in all boxes, I can't use an absolute path since this one is different
on quite some of those boxes.

Given that usually log4j.xml ist stored in

$CATALINA_HOME/webapps/$app/WEB-IF/classes

I thought of something like



That's because our Tomcats are also using log4j instead of Juli.

However, that's close to perfect when using all same Tomcat versions,
but when mixing Tomcat 5.5 and Tomcat 6 on some boxes, this also
doesn't work, since there's no such such as $CATALINA_HOME/common in
Tomcat 6.

Therefore my idea was to use a Java-property being resolved while
pasing log4j.xml, however, the usual meachanism to use Java-properties
inside XML-files doesn't seem to work here.

Actually the property gets resolved perfectly as you can see within
the error-message

log4j:ERROR Could not parse url
[file:/home/tomcat/www/common/classes/log4j.xml].
java.net.MalformedURLException: no protocol: ${log4j.dtd}
   at java.net.URL.(URL.java:567)
   at java.net.URL.(URL.java:464)
   [ ...some more stuff deleted ]

but the protocol ist the problem.

Oh shit - now that I'm typing I *think* I see the error:

One slash after "file:" seems to be missing... I'll have it changed on
Monday when I'm back in the office to

-Dlog4j.dtd=/${CATALINA_HOME}/common/classes/log4j.dtd \

and will let you guys know if that works.

Cheers

Gregor
-- 
just because your paranoid, doesn't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available
@ http://pgpkeys.pca.dfn.de:11371
@ http://pgp.mit.edu:11371/
skype:rc46fi

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Slightly OT: log4j - generic log4j.dtd

2009-04-30 Thread Gregor

andre,
it gets xpanded just perfect, but seems the "file"- protocol is not  
recognized.


so u gotta work a bit more for the chocolate ;)

cheers

gregor

Am 30.04.2009 um 18:13 schrieb André Warnier :


Gregor Schneider wrote:
...

André will not complain, but he has a suggestion :

Considering the error message :

java.net.MalformedURLException: no protocol: ${log4j.dtd}

then either the "${log4j.dtd}" does not get expanded as you expect,  
or else it does but the result is not a valid URL.

So, try :


 [ from catalina.sh ] =
CATALINA_OPTS="  -Xmx256m -server \
-Djava.awt.headless=true \
-Dlog4j.dtd="file:///${CATALINA_HOME}/common/classes/ 
log4j.dtd" \

-Dlog4j.configuration=log4j.xml"

 [ from some log4j.xml ] ===






Now if that works, I get the chocolate.



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: Slightly OT: log4j - generic log4j.dtd

2009-04-30 Thread Peter Crowther
> From: Gregor Schneider [mailto:rc4...@googlemail.com]
> Most of you may know the typical first lines of any
> log4j.xml-config-file:
>
> 
> 

Why does the DTD need to be stored relative to the XML file rather than (say) 
with its correct absolute path, then use the XML parser's preferred solution to 
tell it where the local DTD cache is?

This is just an idle thought - I've no idea how or even whether it would work 
in Tomcat, as I don't know how you'd set up the cache location.  But most XML 
parsers have one *somewhere*.

- Peter

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Slightly OT: log4j - generic log4j.dtd

2009-04-30 Thread André Warnier

Gregor Schneider wrote:
...

André will not complain, but he has a suggestion :

Considering the error message :

java.net.MalformedURLException: no protocol: ${log4j.dtd}

then either the "${log4j.dtd}" does not get expanded as you expect, or 
else it does but the result is not a valid URL.

So, try :



 [ from catalina.sh ] =
CATALINA_OPTS="  -Xmx256m -server \
 -Djava.awt.headless=true \
 -Dlog4j.dtd="file:///${CATALINA_HOME}/common/classes/log4j.dtd" \
 -Dlog4j.configuration=log4j.xml"



 [ from some log4j.xml ] ===







Now if that works, I get the chocolate.



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Slightly OT: log4j - generic log4j.dtd

2009-04-30 Thread Gregor Schneider
Hi guys,

I know it's not a real Tomcat-topic, however, it's close to and I'm
wondering if anyone on this list might come up with some kind of a
smart solution.

Most of you may know the typical first lines of any log4j.xml-config-file:




So far, so bad.

Why bad?

Because every bloody servlet needs it's very own log4j.dtd together
with it's log4j.xml, which is why I'm looking for a smarter solution.

It's a good thing that every servlet has it's onown log4j.xml so that
each servlet can be configured - here I would like the idea of a
cantral log4j-configuration-file.

However, with log4j.dtd things are slightly different since it's
always a file with the same content and I really dislike redundancies.

So my idea was to use ${CATALINA_HOME}, pass this via "-Dlog4j.dtd as
a Java-property to Tomcat and evaluate this property within log4j.xml,
however, that does not seem to work:

 [ from catalina.sh ] =
CATALINA_OPTS="  -Xmx256m -server \
 -Djava.awt.headless=true \
 -Dlog4j.dtd=${CATALINA_HOME}/common/classes/log4j.dtd \
 -Dlog4j.configuration=log4j.xml"



 [ from some log4j.xml ] ===




The result:

log4j:ERROR Could not parse url
[file:/home/tomcat/www/common/classes/log4j.xml].
java.net.MalformedURLException: no protocol: ${log4j.dtd}
at java.net.URL.(URL.java:567)
at java.net.URL.(URL.java:464)
[ ...some more stuff deleted ]

I do no that I can pass a URL, so basically some thing like

http://localhost/mylog4jconf/log4j.dtd";>

should work, but I don't like the idea that I have some directory just
containg some configuration-files which is accessible via http.

I know, I could use a RemoteAdressFilter which just allows connection
from localhost for this webapp, but all this looks a bit too
complicated /awkward to me.

besides, on this box is not only one but a whole bunch of virtual
hosts with obviously different domains running.

Ah well, before André's complaining: ;)

My config is as follows:

Using CATALINA_BASE:   /home/tomcat/www
Using CATALINA_HOME:   /home/tomcat/www
Using CATALINA_TMPDIR: /home/tomcat/www/temp
Using JRE_HOME:   /opt/jdk1.5
Server version: Apache Tomcat/5.5.17
Server built:   Apr 14 2006 02:08:29
Server number:  5.5.17.0
OS Name:Linux
OS Version: 2.6.18-5-686
Architecture:   i386
JVM Version:1.5.0_07-b03
JVM Vendor: Sun Microsystems Inc.

However, same goes for Tomcat 6 with Java 6 and [put your preferred
environment here ]

So guys, anyone smart around here?

Cheers

Gregor
-- 
just because your paranoid, doesn't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available
@ http://pgpkeys.pca.dfn.de:11371
@ http://pgp.mit.edu:11371/
skype:rc46fi

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org