appengine-java-vm-runtime icon indicating copy to clipboard operation
appengine-java-vm-runtime copied to clipboard

how to silence some info logs in the jspc compiler

Open ludoch opened this issue 8 years ago • 8 comments

The GAE staging phase that precompiles the JSP using the jars in a jetty distro still emits: 2016-05-07 15:08:26.379:INFO::main: Logging initialized @555ms 2016-05-07 15:08:26.879:INFO:oajs.TldScanner:main: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

I tried to System.setProperty("org.apache.jasper.servlet.TldScanner.level", "OFF"); in the main process calling jspc, and still sees the log entry.

Also, looking at the generated servlet of the precompiled JSP, I see hard coded path... How it is supposed to work in prod?

private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;

static { _jspx_dependants = new java.util.HashMap<java.lang.String,java.lang.Long>(2); _jspx_dependants.put("jar:file:/Users/ludo/.m2/repository/jstl/jstl/1.2/jstl-1.2.jar!/META-INF/fn.tld", Long.valueOf(1153410282000L)); _jspx_dependants.put("file:/Users/ludo/.m2/repository/jstl/jstl/1.2/jstl-1.2.jar", Long.valueOf(1451600304000L)); }

So far, I do not see any side effect, and I guess this is a bug in the jasper compiler?

ludoch avatar May 07 '16 22:05 ludoch

@ludoch How is the precompilation actually done? Are you using the jetty-maven-plugin? Can you point me at the source?

As for the jspx_dependants, I'm not sure why that is generated into the servlet. Once precompilation has happened, jasper plays no part in the the execution of the servlet, and no part of the servlet seems to call the method getDependants(). So it should not cause a problem, but I'll investigate to see why jasper might be putting it there.

janbartel avatar May 09 '16 00:05 janbartel

@ludoch the jspx_dependents are generated to support on-the-fly recompilation. As that won't happen if the servlet is precompiled, it can safely be ignored.

For the log line "At least one JAR was scanned ..." there are a couple of options I can think of for how to get rid of it:

  1. jasper logs it at level INFO, so if you can successfully configure logging for the org.apache.jasper.servlet.TldScanner class to WARN the message will disappear. Jasper uses the ServiceLoader to look for implementations of the org.apache.juli.logging.Log interface, falling back to java util logging if none are available. Sometimes that gets daisy-chained to other logging mechanisms: for example when running the Jspc class from a maven plugin maven hooks it up to the slf4j SimpleLogger which is configured only from $MAVEN_HOME/conf/logging/simplelogger.properties.
  2. You can set the system property "tomcat.util.scan.StandardJarScanFilter.jarsToSkip" to a comma separated list of globbed jar filenames that should be skipped. Eg "-Dtomcat.util.scan.StandardJarScanFilter.jarsToSkip=jetty-,websocket-".
  3. Depending on how you're running the JspC precompiler we could replace the org.apache.tomcat.util.scan.StandardJarScanner with a different implementation.

janbartel avatar May 09 '16 06:05 janbartel

The jspc process is spawned from the appcfg staging phase, as a standalone java process, with correct classpath setup.... More or less equivalent to

public static void main(String[] args) throws JasperException { if (args.length == 0) { System.out.println(Localizer.getMessage("jspc.usage")); } else { JspC jspc = new JspC() { @Override public String getCompilerClassName() { return LocalCompiler.class.getName(); } }; jspc.setArgs(args); jspc.setCompiler("extJavac"); jspc.setAddWebXmlMappings(true); jspc.execute(); } }

Programmatically setting the logger would be best...

ludoch avatar May 09 '16 22:05 ludoch

This does not belong to this repository (probably should have used basecamp for it) but regardless do we have a solution (seems still to be an issue). @janbartel ?

aozarov avatar Jun 02 '16 00:06 aozarov

@aozarov as mentioned, the simplest thing to do would be to suppress the log message. I don't know what log framework jspc is going to select at runtime in your environment, but there's a good chance it will default to just java util logging, in which case you could do:

Logger.getLogger("org.apache.jasper.servlet.TldScanner").setLevel(Level.WARNING);

janbartel avatar Jun 02 '16 01:06 janbartel

Jasper uses java.util.logging, we could setup either side of the slf4j bindings for jul (either capture or appending) to allow the configuration levels to be controlled in a single place.

joakime avatar Jun 03 '16 00:06 joakime

Need testing with latest Cloud to reproduce (or not)

ludoch avatar Jun 08 '16 23:06 ludoch

direction on how to get the latest cloud sdk are here.

aozarov avatar Jun 09 '16 00:06 aozarov