Re: Fwd: Advice please for Tomcat 8.5.53-dev with log4j2
On 18/3/20 5:54 pm, Luis Rodríguez Fernández wrote: Grande Brian, congrats! Sorry, I've just read your message, a bit late to the party: time ago I had cooked a tomcat9 container + log4j2 with a sample spring-boot app deployed. You can have a look here [1] Thanks very much, Luis. Although just too late to help me, I was pleased to discover it confirmed Mark's advice and my own experience. I guess I missed it from my own searches because I was focussed on the major logging transition between tomcat 7 and the early tomcat 8 version, but your post was prominently identified with tomcat 9. I have a busy weekend with non-self-isolating(!) family and friends, but I have a strong intention to draft an update to the tc8 wiki next week to match the current facts. Probably it will prove trivial for someone to port my change to the tc9 pages. Thanks again for your thoughts, Brian Cheers, Luis [1] https://db-blog.web.cern.ch/blog/luis-rodriguez-fernandez/2019-03-keeping-your-logs-clean-apache-tomcat-9-log4j2-and-spring-boot El mié., 18 mar. 2020 a las 8:44, Brian Burch () escribió: On 18/3/20 5:18 pm, Brian Burch wrote: Could resist tinkering a bit more, but I'll be in trouble because I'm late for dinner!! Success! I have just created the catalina.log file formatted according to my own log4j2.xml. Yes, it was my stupid mistake, but I'll write tomorrow about what it did to make it work. Thanks for listening and advising. It really helped a lot and I wouldn't have cracked it on my own. Brian - 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: Fwd: Advice please for Tomcat 8.5.53-dev with log4j2
Grande Brian, congrats! Sorry, I've just read your message, a bit late to the party: time ago I had cooked a tomcat9 container + log4j2 with a sample spring-boot app deployed. You can have a look here [1] Cheers, Luis [1] https://db-blog.web.cern.ch/blog/luis-rodriguez-fernandez/2019-03-keeping-your-logs-clean-apache-tomcat-9-log4j2-and-spring-boot El mié., 18 mar. 2020 a las 8:44, Brian Burch () escribió: > On 18/3/20 5:18 pm, Brian Burch wrote: > > > > Could resist tinkering a bit more, but I'll be in trouble because I'm > late for dinner!! > > Success! I have just created the catalina.log file formatted according > to my own log4j2.xml. > > Yes, it was my stupid mistake, but I'll write tomorrow about what it did > to make it work. > > Thanks for listening and advising. It really helped a lot and I wouldn't > have cracked it on my own. > > Brian > > - > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > -- "Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better." - Samuel Beckett
Re: Fwd: Advice please for Tomcat 8.5.53-dev with log4j2
On 18/3/20 5:18 pm, Brian Burch wrote: Could resist tinkering a bit more, but I'll be in trouble because I'm late for dinner!! Success! I have just created the catalina.log file formatted according to my own log4j2.xml. Yes, it was my stupid mistake, but I'll write tomorrow about what it did to make it work. Thanks for listening and advising. It really helped a lot and I wouldn't have cracked it on my own. Brian - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Fwd: Advice please for Tomcat 8.5.53-dev with log4j2
On 18/3/20 2:57 pm, Brian Burch wrote: I have done quite a lot of experiments, but I will stick to the case which appears to have produced the most encouraging(!) results. I stumbled across https://logging.apache.org/log4j/2.x/log4j-appserver/index.html. This short page has significant overlap with your suggestions, but there are differences too. I'll compare both before I say much more. Your setenv puts log4j-api-2.13.1.jar on the classpath, but this file does not exist in my log4j2 binary download. Following their advice, I first tried replacing it with log4j-appserver-2.13.1.jar, but startup failed with ClassNotFoundException. Then I added (not replaced) log4j-1.2-api-2.13.1.jar, which seemed to be a good guess. That failed as follows: Exception in thread "main" java.lang.ExceptionInInitializerError Caused by: org.apache.juli.logging.LogConfigurationException: java.lang.reflect.InvocationTargetException at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:136) at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:153) at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:208) at org.apache.catalina.startup.Bootstrap.(Bootstrap.java:51) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:134) ... 3 more Caused by: java.lang.NoClassDefFoundError: org/apache/logging/log4j/LogManager at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:756) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) at java.net.URLClassLoader.access$100(URLClassLoader.java:74) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:363) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:362) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) at org.apache.logging.log4j.appserver.tomcat.TomcatLogger.(TomcatLogger.java:67) ... 8 more However, I suspected my "current best effort" had disabled the internal tomcat logging (juli) but failed to enable log4j2. The message I quoted from catalina.out looked suspiciously like it had been handled by the jvm Logger, which is consistent with your suggestion > I tried building log4j2 from source and gave up. It is a bit of a nuisance that my development system uses both OpenJDK 8 and 11 because I keep forgetting which is required by my different projects. The log4j2 toolchains requirement for java 9 was just too much to contemplate! Clearly, adding log4j-1.2-api-2.13.1.jar did something significant, but I guess the jar is incompatible in some manner? I recall the log4j2 pom.xml has a java.target of 1.7, as well as its toolchain requirement for java 9. I'm doing my very best to build and run tomcat under java 8. Is this relevant, or just a red herring? I downloaded the apache-log4j-2.13.1 binaries, so I will deploy those jars in my tests. I needed to make some minor tweaks to your setenv.bat before I had a syntax-free setenv.sh. Of course, I also replaced your ${CATALINA_BASE} with ${CATALINA_HOME} because that's where I'm currently putting the logging jars. That bootstrap directory also has a copy of tomcat-juli from my java 8 build from 5.8.53-dev source:- -rw-r--r-- 1 tomcat8 tomcat8 51224 Mar 9 17:24 tomcat-juli.jar I also noted from the web advice above that log4j2 looks for it's configuration file under the name log4j2-tomcat.xml, not log4j2.xml. I'm not keen on the advice to deploy the jars to new tomcat directories called catalina.home/log4j2/lib and ./log4j2/conf, so I favour your suggestion of using catalina.home/bin for my first tests. Oh yes... It didn't make any difference whether I called my configuration file conf/log4j2.xml or conf/log4j2-tomcat.xml. I don't think it should matter that the default conf/logging.properties does not exist... wdyt? I really appreciate your thoughtful advice. It would be useful for me to pare the advice down to its essentials and then update the tomcat 8 wiki advice. So, to summarise, I've eliminated a lot of possible solutions and changed the failure
Fwd: Advice please for Tomcat 8.5.53-dev with log4j2
Thanks very much for your speedy and helpful reply, Mark. Stupidly, I had forgotten to re-subscribe to the mailing list, so I found your reply in the archive and cannot reply to it in-line! not really! I stumbled across https://logging.apache.org/log4j/2.x/log4j-appserver/index.html. This short page has significant overlap with your suggestions, but there are differences too. I'll compare both before I say much more. However, I suspected my "current best effort" had disabled the internal tomcat logging (juli) but failed to enable log4j2. The message I quoted from catalina.out looked suspiciously like it had been handled by the jvm Logger, which is consistent with your suggestion. I tried building log4j2 from source and gave up. It is a bit of a nuisance that my development system uses both OpenJDK 8 and 11 because I keep forgetting which is required by my different projects. The log4j2 toolchains requirement for java 9 was just too much to contemplate! I downloaded the apache-log4j-2.13.1 binaries, so I will deploy those jars in my tests. I also noted from the web advice above that log4j2 looks for it's configuration file under the name log4j2-tomcat.xml, not log4j2.xml. I'm not keen on the advice to deploy the jars to new tomcat directories called catalina.home/log4j2/lib and ./log4j2/conf, so I favour your suggestion of using catalina.home/bin for my first tests. I really appreciate your thoughtful advice. It would be useful for me to pare the advice down to its essentials and then update the tomcat 8 wiki advice. Brian - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org