Tomcat 8 enable debug logging to list unneeded jars

蹲街弑〆低调 提交于 2019-11-27 05:06:23
tekNorah

Try debugging for everything by:

  1. Adding this to the end of your logging.properties file located in {CATALINA-HOME}/conf:

    #To see the most detailed level of logging for all classes, uncomment the following line:
    org.apache.catalina.level=FINEST
    
  2. Restart Tomcat

  3. Run the following from Terminal to get a list of jars that need to be skipped (courtesy of @joseph-lust on this post):

    egrep "No TLD files were found in \[file:[^\]+\]" {CATALINA-HOME}/logs/catalina.out -o | egrep "[^]/]+.jar" -o | sort | uniq | sed -e 's/.jar/.jar,\\/g' > ~/skips.txt
    
  4. Open skips.txt in your user home directory

  5. Add this list to {CATALINA-HOME}/conf/catalina.properties after the following line:

    org.apache.catalina.startup.TldConfig.jarsToSkip=
    
  6. Make sure to remove/comment out this when you are done to prevent your log files from growing too large

I am still not sure why this happens, as it seems to work for most to uncomment the TldLocationsCache line.

Crmwind

An easier way, in step 1 of the above post, instead of enabling debugging for everything, limit to org.apache.jasper:

Use this:

org.apache.jasper.level = FINEST

Instead of this:

org.apache.catalina.level=FINEST

I wrote a script to find all jars that don't contain a TLD:

#!/bin/sh
TOMCAT_HOME=/opt/tomcat
for i in `find $TOMCAT_HOME -follow -name "*jar"`
do
    jar tvf $i | grep -i tld > /dev/null
    if [ $? -ne 0 ]; then
        echo "$(basename $i),\\"
    fi
done

Edit the TOMCAT_HOME to match your installation, The script produces a list on the form:

jar1.jar,\
jar2.jar,\
...

that may be pasted into catalina.properties at:

org.apache.catalina.startup.TldConfig.jarsToSkip=
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!