Results 1 to 4 of 4

Thread: How does one inject a log object using commons.logging?

Hybrid View

  1. #1
    Join Date
    May 2006
    Location
    Atlanta, Georgia
    Posts
    2

    Default How does one inject a log object using commons.logging?

    I would like to use org.apache.commons.logging in a class and have that log object created and injected into the target object
    Code:
    import org.apache.commons.logging.Log
    class Foo {
      private Log log;
      public void setLog(Log inLog) {
        this.log = inLog;
      }
      ... other methods, etc.
    }
    
    spring config excerpt...
    <beans>
    
      <!-- use MethodInvokingFactoryBean to get a LogFactory?? -->
      <bean id="logFactory" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetClass"><value>org.apache.commons.logging.LogFactory</value></property>
        <property name="targetMethod"><value>getLog</value></property>
      </bean>
    
      <!-- use the LogFactory to get a Log object?? -->
    
      <bean id="logBean" class="org.apache.commons.logging.Log" factory-bean="logFactory">
        <property name="targetMethod"><value>getLog</value></property>
        <property name="arguments"><value>com.availity.db.edi.AvEdiFecsSelector(sp)</value></property>
      </bean>
    
      <!-- the bean that receives the log bean -->
    
      <bean id="beanWithLog" class="com.compucafe.BeanWithLog">
          <property name="log"><ref local="logBean"/>																       
      </bean>
    </beans>
    I want to set up this log using the spring app context. Is this possible and can anyone tell me what I need to change to get the above config to work.
    Last edited by hamiltonca; Jun 30th, 2006 at 10:06 AM. Reason: Clairification; more details

  2. #2
    Join Date
    Oct 2004
    Location
    Fareham, England
    Posts
    313

    Default

    Hi hamiltonca

    Try this class...

    http://static.springframework.org/sp...api/index.html

    Cheers
    Rick

  3. #3
    Join Date
    May 2006
    Location
    Atlanta, Georgia
    Posts
    2

    Default

    The URL is to the Javadoc index page. I would very much appreciate a pointer to the class you mentioned.

  4. #4
    Join Date
    Oct 2004
    Location
    Fareham, England
    Posts
    313

    Default

    Whoops! Where is the embarrassed smiley?

    http://www.springframework.org/docs/...ctoryBean.html

    Cheers
    Rick

Posting Permissions

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