spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
55.3k stars 37.62k forks source link

Spring logging is not configurable via -Djava.util.logging.config.file option, seems to init own config [SPR-245] #4976

Closed spring-projects-issues closed 19 years ago

spring-projects-issues commented 19 years ago

Andreas Schildbach opened SPR-245 and commented

I discovered that Spring uses java.util.logging for its logging output. Unfortunately, I was not able to alter the logging configuration (log levels etc.) by supplying the -Djava.util.logging.config.file option.

Spring seems to programmatically initialize its own configuration. In my opinion this is not the responsibility of the framework.

In my Tomcat case, I copied the JRE supplied file logging.properties and supplied -Djava.util.logging.config.file to point to that file. Then I edited the line ".level = WARNING". This supresses all INFO logging from my own application. It does not supress however, the INFO messages from Spring. Example:

05.08.2004 11:54:42 org.springframework.web.servlet.mvc.multiaction.MultiActionController setDelegate INFO: Found action method [public org.springframework.web.servlet.ModelAndView de.schildbach.game.presentation.controller.GameDemoController.undo_move(javax.servlet.http.HttpServletRequest,javax.servlet.http.Ht... 05.08.2004 11:54:42 org.springframework.web.servlet.mvc.multiaction.MultiActionController setDelegate INFO: Found action method [public final org.springframework.web.servlet.ModelAndView org.springframework.web.servlet.mvc.AbstractController.handleRequest(javax.servlet.http.HttpServletRequest,javax.servlet.http...


Affects: 1.0.2

spring-projects-issues commented 19 years ago

Juergen Hoeller commented

Spring does not do anything special here: It just uses Commons Logging in a conventional fashion. So this is very likely to be a Commons Logging issue: Check out their docs on how to make it work properly with JDK 1.4.

Of course, if you discover any issues and special solutions for Commons Logging, we can mention them in the Spring docs. So please report them back :-)

Juergen

spring-projects-issues commented 19 years ago

Andreas Schildbach commented

I checked the commons logging (1.04) source (which is very overseeable) and it contains no initialization code for the java.util.logging.LogManager (except in a test case class). Neither does Spring, from what Eclipse tells me.

But I discovered another very strange phenomena:

Log messages in the form...

INFO: Found action method [public org.springframework.web.servlet.ModelAndView de.schildbach.game.presentation.controller.GameController.undo_move(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException] 08.08.2004 14:12:49 org.springframework.web.servlet.mvc.multiaction.MultiActionController setDelegate

...are also logged by JDK 1.4 logging if I set the default .level=OFF and the de.schildbach.level=INFO!

If you look closely, "de.schildbach" appears only in the free text part of the message. The logging class is of couse still "org...MultiActionController". I couldn't find any code part that passes an object reference of my "de.schildbach...GameController" to commons-logging/java.util.logging, so java.util.logging seems to parse the free text! I couldn't find any documentation of this behaviour, so I will try to write an isolated test case and pass this to SUN.

At least the problem does not seem to be related to Spring any more, so I will (try to) close the issue.

Thanks for your help.

spring-projects-issues commented 19 years ago

Juergen Hoeller commented

Agreed that this is not a Spring issue but a rather a Commons Logging one.