• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inject log4j logger

 
zb cong
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello:
there is a logger field in my java class, which is log4j logger type, i want to inject it by spring, but i am not sure how to config the applicationConext for this logger. following does not work, because the Logger has not default constructor.

<bean id="logger" class="org.apache.log4j.Logger"/>

who can help? how to config the spring to inject log4j logger attribute?

thanks.
 
T. Huy Nguyen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haven't tried, but I think you'll need to create a bean factory to create lo4J instances.

Just curious, why do you need to inject a log4j logger instead of creating an static one?
 
zb cong
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes , the bean factory works, as for why we inject the logger, you need to as the designer :-)
thanks
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic