0

I am facing an issue where my tomcat 8.5 does not log to tomcat8-stdout. Where as other log files are created (host-manager, localhost, manager, catalina, localhost_access_log) except for tomcat8-stdout and tomcat8-stderr.

I am trying to debug my web application by using system.out.println(), so i want to output the error at the log. But the log was not created. So it is hard for me to debug.

Below i attached my tomcat logging.properties Any help will be appreciated. Thank you.

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information 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.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler

.handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

1catalina.org.apache.juli.AsyncFileHandler.level = ALL
1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.

2localhost.org.apache.juli.AsyncFileHandler.level = ALL
2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.

3manager.org.apache.juli.AsyncFileHandler.level = FINE
3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.AsyncFileHandler.prefix = manager.

4host-manager.org.apache.juli.AsyncFileHandler.level = ALL
4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.

java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter


############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.AsyncFileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.AsyncFileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = ALL
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.AsyncFileHandler

# For example, set the org.apache.catalina.util.LifecycleBase logger to log
# each component that extends LifecycleBase changing state:
#org.apache.catalina.util.LifecycleBase.level = FINE

# To see debug messages in TldLocationsCache, uncomment the following line:
#org.apache.jasper.compiler.TldLocationsCache.level = FINE
miazocool
  • 13
  • 4

1 Answers1

0

catalina.out (or tomcat8-stdout and tomcat8-stderr that you are mentioning) are NOT proper log files. They are not controlled by the logging configuration.

They are catch of stdout (1) and stderr (2) streams of a program. Catching of those streams (and redirection to files) is done by the shell that launches java executable.

You should look how your java executable is launched for Tomcat and change the command line there. Maybe the streams are not redirected at all, or redirected to a place where there are no write permissions.

Otherwise, if you want a quick solution, just use java.util.logging. It is already available with Java - no additional libraries are needed. E.g.:

java.util.logging.Logger.getLogger("foo").info("My message");
Konstantin Kolinko
  • 3,854
  • 1
  • 13
  • 21
  • Hi thanks for you answer. But currently my app uses java version 1.2. And the java.util.logging is not compatible until 1.4. Can you clarify more on this? "done by the shell that launches java executable." Also this "You should look how your java executable is launched for Tomcat and change the command line there. Maybe the streams are not redirected at all, or redirected to a place where there are no write permissions." I really appreciate your help thank you – miazocool Jul 02 '20 at 09:00
  • It is odd. You have at least java 1.7 if you are running Tomcat 8.5. What exact version of Tomcat 8.5.xx you are using? What is your OS and how did you install Tomcat and how you are launching it? – Konstantin Kolinko Jul 05 '20 at 23:17