This is how I made it work on Tomcat running from within Eclipse:
Find out the path to tomcat running within Eclipse: Where can I view Tomcat log files in Eclipse?
Create a logging.properties
file there. In my case, the path was .../EclipseWorkSpace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf
(You can copy this logging file from within your actual tomcat conf folder.)
Within your application, create a logging.properties
file in src/main/resources
.
(did not work when i directly created in WEB-INF/classes
as mentioned in tomcat documentation :
Example logging.properties for the servlet-examples web application to
be placed in WEB-INF/classes inside the web application:
from https://tomcat.apache.org/tomcat-9.0-doc/logging.html
)
set your tomcat logging parameters in the above file, which overrides the default logging.properties
file from /.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf
from inside your app:
handlers= java.util.logging.ConsoleHandler
.level= FINE
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
This will log 'FINE' level logs from Tomcat.
Set logging properties in your jersey app:
register(new LoggingFeature(Logger.getLogger(MyApplication.class.getName()), Level.INFO, LoggingFeature.Verbosity.PAYLOAD_TEXT, 2048));
OR
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>org.glassfish.jersey.logging.LoggingFeature</param-value>
</init-param>
This will only log 'INFO' logs from jersey.
So, 4 and 5 effectively means that Tomcat would log all FINE logs, but Jersey would only log INFO logs, so in your log file (catalina.out) , you will only see INFO logs from Jersey, but FINE logs from everything else in Tomcat.