logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul <pgbak...@gmail.com>
Subject Re: Application Server integration in Tomcat
Date Fri, 22 Feb 2019 16:27:12 GMT
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 is there, but talks about Log4j 1 and also details how 
you need to replace the tomcat-juli(-adapters).jars, which I think is 
not required anymore, see this case: 
https://bz.apache.org/bugzilla/show_bug.cgi?id=58588. However, that case 
seems to suggest that the way to replace tomcats internal logging is 
through JUL....

So, I gave JUL another shot:

- with all the log4j-core/api/jul/ and a log4j2.properties on the 
classpath set through  setenv.sh, I'm able to replace the internal 
logging of Tomcat using Log4j2. So far so good.

- For the logging from the single webaap/WAR I'll ever deploy in this 
tomcat instance, I have custom appenders that have static fields that 
are accessed from within the deployed webapp and through the log4j2 
appender interface methods. Hence, log4j2 and the webapp need to use the 
same classloader (hierarchy), otherwise they'll be looking at teh same 
class loaded through different classloaders, thus different instances of 
the static field. I've got log4j2-web.jar and the jar containing my 
custom appenders both in the WEB-INF/lib folder of my webapp + a 
log4j2.properties in the WEB-INF folder, but then Log4J can't find the 
custom appenders. If I put the jar with the custom appenders on the 
classpath via Tomcat's setenv.sh, Log4J initializes properly, but the 
WebApp and Log4j seem to use 2 different classloaders, thus I run into 
the problem with multiple instances of the static field

Is there any setup I can use that works in this scenario?

Paul

On 20/02/2019 12:26, Apache wrote:
> 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 <pgbakker@gmail.com> wrote:
>>
>> 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 <remko.popma@gmail.com wrote:
>>>
>>> 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
>>> directory.
>>>
>>> Also, this user manual page may be useful:
>>> https://logging.apache.org/log4j/2.x/manual/webapp.html (and maybe this
>>> one: https://logging.apache.org/log4j/2.x/manual/logsep.html).
>>>
>>> Remko.
>>>
>>> (Shameless plug) Every java main() method deserves http://picocli.info
>>>
>>>> On Feb 20, 2019, at 1:03, Paul <pgbakker@gmail.com> wrote:
>>>>
>>>> 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
>>> directory.
>>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>

---
This email has been checked for viruses by AVG.
https://www.avg.com


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message