Re: Application Server integration in Tomcat

2019-02-25 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Ralph, On 2/25/19 10:16, Ralph Goers wrote: > Here is an answer to your question regarding using Log4j for > tomcat internal logging. I have seen lots of tomcat deployments > where catalina.out was a problem. Tomcat provides no rolling > mechanism a

Re: Application Server integration in Tomcat

2019-02-25 Thread Ralph Goers
Here is an answer to your question regarding using Log4j for tomcat internal logging. I have seen lots of tomcat deployments where catalina.out was a problem. Tomcat provides no rolling mechanism and over months the file can become enormous. Ralph > On Feb 25, 2019, at 6:59 AM, Christopher Sc

Re: Application Server integration in Tomcat

2019-02-25 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Paul, On 2/24/19 04:46, Paul wrote: > Ghee, that was it, at least for getting the internal Tomcat logging > to go through Log4j. > > It didn't solve my static field thing, but that one I also figured > out. Not 100% sure my reasoning is correct, bu

Re: Application Server integration in Tomcat

2019-02-24 Thread Ralph Goers
I have been able to get this working but I have not yet added a Plugin to validate the last part. I placed the log4j-api, log4j-core, and log4j-appserver jars in the directory picked up by the bootstrap class loader along with the log4j2-tomcat.xml. That successfully used log4j for logging. I th

Re: Application Server integration in Tomcat

2019-02-24 Thread Paul
Ghee, that was it, at least for getting the internal Tomcat logging to go through Log4j. It didn't solve my static field thing, but that one I also figured out. Not 100% sure my reasoning is correct, but I think it's due to how classloading works in Servlets and thus in Tomcat (by default): th

Re: Application Server integration in Tomcat

2019-02-22 Thread Ralph Goers
I just noticed that you said you have setenv.sh set to CLASSPATH=“$CATALINA_HOME/lib/*” That will find the jars but it won’t find your configuration file. You need to specify CLASSPATH=“$CATALINA_HOME/lib/*:${CATALINA_HOME}/lib” Note that lib is specified twice, once with “/*” after it and once

Re: Application Server integration in Tomcat

2019-02-22 Thread Ralph Goers
I followed the instructions at http://logging.apache.org/log4j/2.x/log4j-appserver/index.html with Tomcat 9 and I was able to have tomcat use Log4j for logging without any problems. I will try adding a web app that uses Log4j 2 n

Re: Application Server integration in Tomcat

2019-02-22 Thread Paul
I'll double-check again, but I'm pretty confident the class is there only once On Fri, Feb 22, 2019, 9:33 PM Ralph Goers wrote: > If there the class exists in only one jar/directory then that class will > only be loaded once by the class loader that manages the jar or directory. > The only way y

Re: Application Server integration in Tomcat

2019-02-22 Thread Ralph Goers
If there the class exists in only one jar/directory then that class will only be loaded once by the class loader that manages the jar or directory. The only way you can have two instances of the class is if it is present in two different class loaders. In the case of Tomcat, that would mean it h

Re: Application Server integration in Tomcat

2019-02-22 Thread Paul
The 'error' I get is that the static field on my custom appender class is null when accessed from my webapp, long after log4j is initialized, while the appender constructor that log4j called sets is value. And the access to that static field happens long after log4j is initialized. So my conclusi

Re: Application Server integration in Tomcat

2019-02-22 Thread Ralph Goers
Another possibility - Take a look at “Advanced Configuration” at http://tomcat.apache.org/tomcat-9.0-doc/class-loader-howto.html . If you define a server loader and place the Log4j jars there then Tomcat should use Log4j for log

Re: Application Server integration in Tomcat

2019-02-22 Thread Ralph Goers
FWIW, Looking at the Tomcat 9.0 code I see the same ServiceLoader code as in Tomcat 8.5, so the log4j-appserver code should still work. Ralph > On Feb 22, 2019, at 11:27 AM, Ralph Goers wrote: > > Tomcat’s class loader will be a parent of the web app class loader. That > means the log4j-relat

Re: Application Server integration in Tomcat

2019-02-22 Thread Ralph Goers
Tomcat’s class loader will be a parent of the web app class loader. That means the log4j-related classes placed in the tomcat class loader won’t be able to access anything in your web-app class loader. But your application should have no problem accessing them in tomcat’s class loader provided y

Re: Application Server integration in Tomcat

2019-02-22 Thread Paul
Hi Ralph, See in between the lines. Curious to hear what your take is on the classloader usage which is what is causing my issues. Paul On 22/02/2019 18:43, Ralph Goers wrote: I am not really clear on what you are trying to achieve so this answer is making some guesses. A typical tomcat d

Re: Application Server integration in Tomcat

2019-02-22 Thread Ralph Goers
I am not really clear on what you are trying to achieve so this answer is making some guesses. A typical tomcat deployment will have a boot class loader, the tomcat class loader and each web app will have its own class loader. Tomcat’s logging has to happen using Tomcat’s class loader while th

Re: Application Server integration in Tomcat

2019-02-22 Thread Paul
Tnx I've also tried myself locally on my laptop (Wind10, Tomcat 9.0.16, log4j2 2.11.2, Java 1.8.0_162) but the exact same problem. I've also looked at the docs on the Tomcat side: for Tomcat 9 the docs on logging don't mention this mechanism to use log4j anymore. On the 8.0 documentation it

Re: Application Server integration in Tomcat

2019-02-20 Thread Apache
Ok. I will try it myself with both of those and let you know, but it might take a couple of days. Ralph > On Feb 19, 2019, at 11:58 PM, Paul wrote: > > With log4j-web on the classmate the INFO statements you mentioned > disappear, but the problem of internal tomcat logging via log4j isn't > so

Re: Application Server integration in Tomcat

2019-02-19 Thread Paul
With log4j-web on the classmate the INFO statements you mentioned disappear, but the problem of internal tomcat logging via log4j isn't solved. And I've went through but those links many times, tried everything I could find there, but no avail On Tue, Feb 19, 2019, 11:26 PM Remko Popma Hi Paul,

Re: Application Server integration in Tomcat

2019-02-19 Thread Paul
Yes, tomcat 9 on java 11 On Wed, Feb 20, 2019, 6:24 AM Ralph Goers Were you using Tomcat 8.5 or greater? The instructions on the > log4j-appserver page should work if you are using that version of Tomcat. > Prior to that you will have to follow Tomcat’s instructions on how to > replace the loggin

Re: Application Server integration in Tomcat

2019-02-19 Thread Ralph Goers
Were you using Tomcat 8.5 or greater? The instructions on the log4j-appserver page should work if you are using that version of Tomcat. Prior to that you will have to follow Tomcat’s instructions on how to replace the logging framework. Ralph > On Feb 19, 2019, at 9:03 AM, Paul wrote: > > Hi

Re: Application Server integration in Tomcat

2019-02-19 Thread Remko Popma
Hi Paul, Please try adding the log4j-web jar to the classpath: > INFO StatusLogger Log4j appears to be running in a Servlet environment, but > there's no log4j-web module available. If you want better web container > support, please add the log4j-web JAR to your web archive or server lib > dire