Tomcat logging.properties formatter not taking effect
Asked Answered
L

1

1

I'm trying to adjust logging for catalina. My logging.properties for Tomcat looks like:

handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler

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

1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = my-catalina.
1catalina.org.apache.juli.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=tomcat: [%1$tc] %4$s: %2$s - %5$s %6$s%n

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

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

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

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

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

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

But I can't get to work formatter for the output:

1catalina.org.apache.juli.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=tomcat: [%1$tc] %4$s: %2$s - %5$s %6$s%n

What I'm getting in my-catalina.2018-03-16.log looks like:

Mar 16, 2018 9:41:11 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 585 ms
Mar 16, 2018 9:41:11 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 16, 2018 9:41:11 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.22

Any thoughts on that?

Laminate answered 16/3, 2018 at 13:59 Comment(0)
T
2

But I can't get to work formatter for the output

I would assume that you'll have to modify the start up script so the format property is present before the SimpleFormatter class is loaded.

The format is forever set once the class is loaded so if the class is loaded before the logging properties is read what you place in the file will be ignored.

Thought answered 16/3, 2018 at 19:11 Comment(2)
"to modify the start up script" - on the server or IntelliJ? I'm not familiar with that part :/Laminate
@Laminate You'll have to dig for the startup script that IntelliJ is using. You should be able to locate it in the tomcat home or tomcat domain used by IntelliJ.Thought

© 2022 - 2024 — McMap. All rights reserved.