Results 1 to 3 of 3

Thread: Is there a way to inject the logger instance in a bean configuration?

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Posts
    1

    Question Is there a way to inject the logger instance in a bean configuration?

    I'm a newbie in Spring and I was just wondering if there's a way to set the code below as a bean property?

    private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(<<Name of Class>>.class.getName());

    The intention is to avoid having to code this line in every class.


    Thanks.

  2. #2
    Join Date
    Sep 2004
    Posts
    602

    Default

    Quote Originally Posted by glicup
    I'm a newbie in Spring and I was just wondering if there's a way to set the code below as a bean property?

    private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(<<Name of Class>>.class.getName());

    The intention is to avoid having to code this line in every class.


    Thanks.
    Even if there is you would have to do it for each class, as each class needs a separate Logger. Why not just set up an Eclipse template that plugs in a Logger for you when you create a new class ?

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Actually there is a FactoryBean (org.sf.beans.factory.config.CommonsLogFactoryBean ) that injects log instances; however, as Paul mentioned what you want is actually a template that should be applied when the class is created (something that is probably already supported by your IDE).
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •