Meaningless Drivel is fun!*
The moose likes Spring and the fly likes inject log4j logger Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "inject log4j logger" Watch "inject log4j logger" New topic
Author

inject log4j logger

zb cong
Ranch Hand

Joined: Jan 14, 2002
Posts: 416
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

Joined: Nov 02, 2010
Posts: 57
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?


My material for SCJP (2008), SCWCD (2010), SCBCD (2010). About me
zb cong
Ranch Hand

Joined: Jan 14, 2002
Posts: 416
yes , the bean factory works, as for why we inject the logger, you need to as the designer :-)
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inject log4j logger
 
Similar Threads
logs for jakarta-tomcat-5.0.28
How to pass Log4J XML path in Custom Logger
Struts ExceptionHandler - configure using Spring
Log4j in Spring
Log4j � Custom levels don�t work