Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Commons Logging setup in AnnotationUtils causes early initialization of logging system [SPR-12329] #16934

Closed
spring-projects-issues opened this issue Oct 13, 2014 · 2 comments
Assignees
Labels
in: core status: backported type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Oct 13, 2014

Yanming Zhou opened SPR-12329 and commented

I am using log4j, and using a custom system property "app.home" placeholder in log4j configuration.

<param name="file" value="${app.home}/logs/application.log"/>

set system property with a ServletContextListener.contextInitialized(), It works fine util I have more than one WebApplicationInitializers, after my investigation, I found it caused by SpringServletContainerInitializer

AnnotationAwareOrderComparator.sort(initializers);

AnnotationAwareOrderComparator depends on org.springframework.core.annotation.AnnotationUtils, AnnotationUtils used commons-logging, It will make my log4j premature, "app.home" will eval as empty since SpringServletContainerInitializer is executed before any ServletContextListener.contextInitialized().

please remove logging from AnnotationUtils, it's not useful. or use java.util.logging instead.


Affects: 4.0.7, 4.1.1

Issue Links:

  • #16493 AnnotationUtils.findAnnotation fails with poor diagnostics if it encounters an Annotation that references an unloadable class
  • #16930 AnnotationUtils provides poor diagnostics if getDeclaredAnnotations throws an exception

Backported to: 4.0.8

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 20, 2014

Juergen Hoeller commented

As a compromise for a consistent logging experience, we keep using Commons Logging in AnnotationUtils but lazily initialize the logger when actually needed, i.e. only in case of an introspection failure.

If you do run into an introspection failure on a WebApplicationInitializer class, you will want to fix this anyway - and in all regular scenarios, there won't be any introspection failures to begin with.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 20, 2014

Yanming Zhou commented

Thanks, it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: backported type: bug
Projects
None yet
Development

No branches or pull requests

2 participants