Issue
My goal is to have all app-level logging go to my app log file. My problem is that while a lot of my debug/info/error messages make it to STDOUT/File etc... here is one error that only shows in my tomcat9 log:
4-Jun-2018 08:55:29.050 SEVERE [http-nio-82-exec-6] org.apache.catalina.core.ApplicationDispatcher.invoke Servlet.service() for servlet [jsp] threw exception
org.apache.jasper.JasperException: /WEB-INF/jsp/di_queue.jsp (line: [110], column: [8]) The function [isCurrentUser] cannot be located with the specified prefix
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:292)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:115)
at org.apache.jasper.compiler.Validator$ValidateVisitor$1FVVisitor.visit(Validator.java:1603)
at org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:135)
I am using jdk 10, Spring 5.0.5, Hibernate 5.3, Logback 1.2.3
Here is my logback.xml
<configuration scan="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.directwebremoting" level="trace"
additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<logger name="org.apache.tiles" level="info"
additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<logger name="org.apache.jasper.compiler" level="info"
additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<root level="error">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Here is my ivy.xml
<ivy-module version="2.0">
<info organisation="org.apache" module="ews" />
<configurations defaultconfmapping="default">
<conf name="default" />
<conf name="compile" description="compile dependencies" extends="default" />
<conf name="runtime" description="runtime dependencies" extends="default" />
<conf name="test" description="test dependencies" extends="default" />
</configurations>
<dependencies>
<dependency org="org.hibernate" name="hibernate-core" rev="5.3.0.Final">
</dependency>
<dependency org="org.hibernate" name="hibernate-jcache"
rev="5.3.0.Final" />
<!-- just for ehcahce 2? -->
<!-- <dependency org="org.hibernate" name="hibernate-ehcache" rev="5.3.0.Final"
/> -->
<!-- needed or whole hibernate spring config does not start -->
<dependency org="org.springframework.boot" name="spring-boot-starter-cache"
rev="2.0.2.RELEASE" />
<dependency org="javax.cache" name="cache-api" rev="1.1.0" />
<dependency org="org.ehcache" name="ehcache" rev="3.5.2" />
<dependency org="org.springframework" name="spring-orm"
rev="5.0.6.RELEASE" />
<dependency org="org.springframework" name="spring-core"
rev="5.0.6.RELEASE" />
<dependency org="ch.qos.logback" name="logback-access" rev="1.2.3" />
<dependency org="org.springframework" name="spring-webmvc"
rev="5.0.6.RELEASE" />
<dependency org="org.springframework" name="spring-web"
rev="5.0.6.RELEASE" />
<dependency org="org.springframework" name="spring-context"
rev="5.0.6.RELEASE" />
<dependency org="org.springframework.boot" name="spring-boot-starter-logging"
rev="2.0.2.RELEASE" />
<!-- https://mvnrepository.com/artifact/org.directwebremoting/dwr rev="2.0.1"
rev="3.0.2-RELEASE" -->
<dependency org="org.directwebremoting" name="dwr"
rev="3.0.2-RELEASE" />
<dependency org="dom4j" name="dom4j" rev="1.6.1" />
<dependency org="net.sf.jasperreports" name="jasperreports"
rev="3.6.1" /><!-- 6.6.0 -->
<dependency org="jstl" name="jstl" rev="1.2" />
<dependency org="javax.servlet" name="servlet-api" rev="2.5" />
<dependency org="net.sf.supercsv" name="super-csv-dozer"
rev="2.4.0" />
<!-- <dependency org="org.slf4j" name="jcl-over-slf4j" rev="1.7.22" />
<dependency org="org.apache.logging.log4j" name="log4j-slf4j-impl" rev="2.7"
/> <dependency org="org.apache.logging.log4j" name="log4j-api" rev="2.7"
/> <dependency org="org.apache.logging.log4j" name="log4j-core" rev="2.7"
/> -->
<!-- for the ant classes remove after ant jrc working -->
<!-- <dependency org="commons-logging" name="commons-logging" rev="1.2"
/> <dependency org="org.codehaus.groovy" name="groovy-all" rev="1.5.5" />
<dependency org="org.eclipse.jdt.core.compiler" name="ecj" rev="4.6.1" /> -->
<dependency org="org.apache.tiles" name="tiles-jsp" rev="3.0.8" />
<dependency org="org.apache.tiles" name="tiles-core" rev="3.0.8" />
<dependency org="org.apache.tiles" name="tiles-api" rev="3.0.8" />
<dependency org="org.apache.tiles" name="tiles-servlet"
rev="3.0.8" />
<dependency org="commons-fileupload" name="commons-fileupload"
rev="1.3.3" />
<dependency org="javax.mail" name="javax.mail-api" rev="1.6.1" />
<dependency org="com.mchange" name="c3p0" rev="0.9.5.2" />
<dependency org="org.json" name="json" rev="20180130" />
<dependency org="javax.json" name="javax.json-api" rev="1.1.2" />
<dependency org="commons-validator" name="commons-validator"
rev="1.6" />
<dependency org="org.mozilla" name="rhino" rev="1.7R1" />
<!-- <dependency org="org.acegisecurity" name="acegi-security" rev="1.0.4"
/> -->
<dependency org="org.springframework.security" name="spring-security-web"
rev="5.0.5.RELEASE" />
<dependency org="org.springframework.security" name="spring-security-config"
rev="5.0.5.RELEASE" />
<dependency org="com.lowagie" name="itext" rev="2.1.7" />
<dependency org="org.apache.tomcat" name="tomcat-catalina"
rev="9.0.8" />
<dependency org="com.microsoft.sqlserver" name="mssql-jdbc"
rev="6.4.0.jre9" />
<!-- https://www.concretepage.com/forum/thread?qid=531 -->
<dependency org="javax.xml.bind" name="jaxb-api" rev="2.3.0" />
<dependency org="oro" name="oro" rev="2.0.8" />
<dependency org="org.apache.commons" name="commons-lang3"
rev="3.7" />
<dependency org="commons-fileupload" name="commons-fileupload"
rev="1.3.3" />
</dependencies>
</ivy-module>
Seems like JSP/view/tiles/dwr errors are the ones I am missing in STDOUT
Solution
This Servlet related exception logs are handled by Tomcat internal logging library which is a customised java.util.logging.
According to this :
The calls to javax.servlet.ServletContext.log(...) to write log messages are handled by internal Tomcat logging. Such messages are logged to the category named
org.apache.catalina.core.ContainerBase.[${engine}].[${host}].[${context}]
To overwrite the global Tomcat logging configuration , try to put a java.util.logging 's properties file logging.properties
in /WEB-INF/classes/
and configure the above logger log to a file handler , somethings like this:
handlers =java.util.logging.FileHandler
java.util.logging.FileHandler.level = INFO
java.util.logging.FileHandler.formatter = org.apache.juli.OneLineFormatter
java.util.logging.FileHandler.pattern = /temp/app.log
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = java.util.logging.FileHandler
Answered By - Ken Chan