Re: Getting Tomcat internal logging working
чт, 7 нояб. 2019 г. в 05:44, Christopher Schultz : > > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA256 > > All, > > I can't believe I'm having trouble with this, but I'm struggling with > enabling logging. > > I'm experimenting with the CsrfPreventionFilter, which currently has > zero logging at all in it. So, first I modified the code to add: > > + private final Log log = > LogFactory.getLog(CsrfPreventionFilter.class); > > and, later > > if (nonceCache == null || previousNonce == null || > !nonceCache.contains(previousNonce)) { > + log.trace("nonceCache=" + (null == nonceCache ? "(null)" : > nonceCache.cache)); > + log.trace("previousNonce=" + previousNonce); > + log.trace("nonceCache.contains=" + (null == nonceCache ? > "(null)" : nonceCache.contains(previousNonce))); > > res.sendError(getDenyStatus()); > return; > } Are you modifying the correct file? (1. At build time it is copied to the output directory. Are you modifying the source or the copy? 2. The configuration file is enabled via -Djava.util.logging.config.file= system property that is set by catalina script. If you run Tomcat in some other way, that system property may be not set at all. (E.g. when running Tomcat from within Eclipse IDE.) ) > Finally, I modified these lines in $CATALINA_BASE/conf/logging.propertie > s: > - - java.util.logging.ConsoleHandler.level = FINE > + java.util.logging.ConsoleHandler.level = ALL > > ... > > + org.apache.catalina.filters.level=ALL Looks OK. Personally I never use 'ALL', but it should be OK. I prefer to use FINE, FINER or FINEST. https://docs.oracle.com/javase/7/docs/api/java/util/logging/Level.html#ALL > When running, I see no logging when I'm expecting to see things in > catalina.out. I changed these lines from log.trace() to > System.err.println() and they do indeed show up. > > What am I missing? > Best regards, Konstantin Kolinko - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Getting Tomcat internal logging working
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 All, I can't believe I'm having trouble with this, but I'm struggling with enabling logging. I'm experimenting with the CsrfPreventionFilter, which currently has zero logging at all in it. So, first I modified the code to add: + private final Log log = LogFactory.getLog(CsrfPreventionFilter.class); and, later if (nonceCache == null || previousNonce == null || !nonceCache.contains(previousNonce)) { + log.trace("nonceCache=" + (null == nonceCache ? "(null)" : nonceCache.cache)); + log.trace("previousNonce=" + previousNonce); + log.trace("nonceCache.contains=" + (null == nonceCache ? "(null)" : nonceCache.contains(previousNonce))); res.sendError(getDenyStatus()); return; } Finally, I modified these lines in $CATALINA_BASE/conf/logging.propertie s: - - java.util.logging.ConsoleHandler.level = FINE + java.util.logging.ConsoleHandler.level = ALL ... + org.apache.catalina.filters.level=ALL When running, I see no logging when I'm expecting to see things in catalina.out. I changed these lines from log.trace() to System.err.println() and they do indeed show up. What am I missing? - -chris -BEGIN PGP SIGNATURE- Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl3DhQoACgkQHPApP6U8 pFh9WQ/+P6GkuDL9YVWq2+Uv++e8dCgYSGo1hNr+1olun5+LzkWl9y4hfRpineVV R4KHaeEoq24VJZWN8PmzZRZnkETLnATGZ82vTzVDJi+pfbxn+bC4e3wCRedUb6p1 Ieoro6II5p/621aQkClMQMht/ruu2PpEHx7qPjYa77x+fl4crDCq4cJ8fLeACUGZ tTKnEZYqw/vE6eUozLE/KDYVSRmsvzE6PZ7Rk8Duv8k2dFHovwXoTkvPxZ8o8q/v lWl20iPIsy+8otWbWx+/9fmm8LnPmD3cd1FhaczL86omOp1VYfMFW9KsMQMcZTaw 4jVkb9uJva1eupJu4CoNCecCRiOK0/RznkuA4wO210TqUC4pzSoZHQVIzM+oO9J0 JYrbR3dqmKXaBrSB7vGt2SnooD4QJPRTVGpYRmt8Xe42uXrZ1OPawb7fnOZntjQg MvvFZa4QcUv69jBntfaopiMFLU+PcQMH6xVLw8dy1EGRAcEzD+FnVhNpir82NdXD ZcVUGeUZrt+rw6+MLr6i8Due0hd5WYaaggH/obDle9lgaySB81jSsZTKwqTBo4Tv KFKuL5NTKnQ/3vsWngRW/KuX50LDVXdY3Uhs0ZDKeUj/nQipc16s//KH4E7jaSsh opaJDbUL+WU9tP/EWTmxTUptaNO6wz6do/QDIfEGk2RePvWSjpA= =Psm0 -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Intermittent JSP Caching/Compiling Issue while under load
I've found the root cause. When checking the timestamps of JSPs, the JSP engine (because it has to access all resources via the Servlet API) requests a URL for the JSP, opens a connection to the URL and then checks the last modified time. This goes directly to the on-disk file. When reading the content, the request goes via the static resource cache because we can intercept the call to ServletContext.getResourceAsStream() The problem is the following sequence: - request for JSP - no change in JSP timestamp found - cache re-validated (for 5s by default) - JSP is modified (within 5s) - request for JSP (within 5s) - change in JSP timestamp found - JSP content read (sees cached version rather than new version) So we end up with the old version of the JSP content with the updated last modification time. I'm currently looking at options to return a URL for the resource where we can intercept the call to URLConnection.getLastModified(). Mark - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org