Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set level logging to DEBUG in Tomcat?

I would like to set level logging to DEBUG in tomcat but in console nevertheless only INFO and WARN output. Could anybody tell me what's wrong?

My C:\tomcat\logging.properties:

# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements.  See the NOTICE file distributed with # this work for additional DEBUGrmation regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License.  You may obtain a copy of the License at # #     http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.  handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler  .handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler  ############################################################ # Handler specific properties. # Describes specific configuration DEBUG for Handlers. ############################################################  1catalina.org.apache.juli.FileHandler.level = DEBUG 1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs 1catalina.org.apache.juli.FileHandler.prefix = catalina.  2localhost.org.apache.juli.FileHandler.level = DEBUG 2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs 2localhost.org.apache.juli.FileHandler.prefix = localhost.  3manager.org.apache.juli.FileHandler.level = DEBUG 3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs 3manager.org.apache.juli.FileHandler.prefix = manager.  4host-manager.org.apache.juli.FileHandler.level = DEBUG 4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs 4host-manager.org.apache.juli.FileHandler.prefix = host-manager.  java.util.logging.ConsoleHandler.level = DEBUG java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter   ############################################################ # Facility specific properties. # Provides extra control for each logger. ############################################################  org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = DEBUG org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler  org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = DEBUG org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler  org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = DEBUG org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler  # For example, set the com.xyz.foo logger to only log SEVERE # messages: #org.apache.catalina.startup.ContextConfig.level = DEBUG #org.apache.catalina.startup.HostConfig.level = DEBUG #org.apache.catalina.session.ManagerBase.level = DEBUG #org.apache.catalina.core.AprLifecycleListener.level=DEBUG 

Example of my log:

INFO: Deploying configuration descriptor manager.xml 08.11.2010 1:06:42 org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive spring-mvc-trial.war 08.11.2010 1:06:46 org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory docs 08.11.2010 1:06:46 org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory examples 08.11.2010 1:06:46 org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory ROOT 08.11.2010 1:06:46 org.apache.coyote.http11.Http11AprProtocol start INFO: Starting Coyote HTTP/1.1 on http-8080 08.11.2010 1:06:46 org.apache.coyote.ajp.AjpAprProtocol start INFO: Starting Coyote AJP/1.3 on ajp-8009 08.11.2010 1:06:46 org.apache.catalina.startup.Catalina start INFO: Server startup in 3777 ms 08.11.2010 1:09:36 org.apache.coyote.http11.Http11AprProtocol pause INFO: Pausing Coyote HTTP/1.1 on http-8080 08.11.2010 1:09:36 org.apache.coyote.ajp.AjpAprProtocol pause INFO: Pausing Coyote AJP/1.3 on ajp-8009 08.11.2010 1:09:37 org.apache.catalina.core.StandardService stop INFO: Stopping service Catalina 08.11.2010 1:09:37 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc SEVERE: The web application [/spring-mvc-trial] registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 08.11.2010 1:09:37 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/spring-mvc-trial] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak. 08.11.2010 1:09:38 org.apache.coyote.http11.Http11AprProtocol destroy INFO: Stopping Coyote HTTP/1.1 on http-8080 08.11.2010 1:09:38 org.apache.coyote.ajp.AjpAprProtocol destroy INFO: Stopping Coyote AJP/1.3 on ajp-8009 
like image 212
gennad Avatar asked Nov 07 '10 19:11

gennad


People also ask

How do I change the log level to debug?

To change log levels as a root user, perform the following: To enable debug logging, run the following command: /subsystem=logging/root-logger=ROOT:change-root-log-level(level=DEBUG) To disable debug logging, run the following command: /subsystem=logging/root-logger=ROOT:change-root-log-level(level=INFO)

How do I enable debug logging?

Launch Event Viewer. Select View\Show Analytic and Debug Logs. Navigate to Event Viewer (Local)\Applications and Service Logs\Microsoft\User Experience Virtualization\App Agent. Right-click on Debug under App Agent and select Enable Log.

What is debug logging level?

A debug level is a set of log levels for debug log categories, such as Database , Workflow , and Validation . A trace flag includes a debug level, a start time, an end time, and a log type. The log types are DEVELOPER_LOG , USER_DEBUG , and CLASS_TRACING .

How do I set the default level of logging in Tomcat?

The default logging.properties in the JRE specifies a ConsoleHandler that routes logging to System.err. The default conf/logging.properties in Apache Tomcat also adds several AsyncFileHandler s that write to files. A handler's log level threshold is INFO by default and can be set using SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST or ALL.

How do I enable debug logging for Tomcat internals?

To enable debug logging for part of Tomcat's internals, you should configure both the appropriate logger (s) and the appropriate handler (s) to use the FINEST or ALL level. e.g.:

What is debug level in Tomcat?

Be warned: a level of DEBUG will produce megabytes of logging and slow startup of Tomcat. This level should be used sparingly when debugging of internal Tomcat operations is required. Your web applications should certainly use their own log4j configuration. This is valid with the above configuration.

How do I collect logging from Tomcat?

You can also target specific packages to collect logging from and specify a level. You can set debugging from Tomcat by ensuring that ConsoleHandler (or FileHandler) level is also set to collect this threshold, so FINEST or ALL should be set.


2 Answers

Firstly, the level name to use is FINE, not DEBUG. Let's assume for a minute that DEBUG is actually valid, as it makes the following explanation make a bit more sense...

In the Handler specific properties section, you're setting the logging level for those handlers to DEBUG. This means the handlers will handle any log messages with the DEBUG level or higher. It doesn't necessarily mean any DEBUG messages are actually getting passed to the handlers.

In the Facility specific properties section, you're setting the logging level for a few explicitly-named loggers to DEBUG. For those loggers, anything at level DEBUG or above will get passed to the handlers.

The default logging level is INFO, and apart from the loggers mentioned in the Facility specific properties section, all loggers will have that level.

If you want to see all FINE messages, add this:

.level = FINE 

However, this will generate a vast quantity of log messages. It's probably more useful to set the logging level for your code:

your.package.level = FINE 

See the Tomcat 6/Tomcat 7 logging documentation for more information. The example logging.properties file shown there uses FINE instead of DEBUG:

... 1catalina.org.apache.juli.FileHandler.level = FINE ... 

and also gives you examples of setting additional logging levels:

# For example, set the com.xyz.foo logger to only log SEVERE # messages: #org.apache.catalina.startup.ContextConfig.level = FINE #org.apache.catalina.startup.HostConfig.level = FINE #org.apache.catalina.session.ManagerBase.level = FINE 
like image 124
Richard Fearn Avatar answered Sep 28 '22 18:09

Richard Fearn


JULI logging levels for Tomcat

SEVERE - Serious failures

WARNING - Potential problems

INFO - Informational messages

CONFIG - Static configuration messages

FINE - Trace messages

FINER - Detailed trace messages

FINEST - Highly detailed trace messages

You can find here more https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/pasoe-admin/tomcat-logging.html

like image 21
Andrew Bezuglov Avatar answered Sep 28 '22 19:09

Andrew Bezuglov