Announcement Announcement Module
Collapse
No announcement yet.
Log4j configuration setting. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Log4j configuration setting.

    I am trying to use Core's IoC and DI for my application no WEB related stuff (no dispatcher servlet and no web.xml). Initially I used to call simple API
    Code:
    PropertyConfigurator.configure( "./resource/log4j.config.xml" );
    and everything worked fine.

    Now I decided to move the spring way, and added the spring capabilities and the metadata in form of XML.

    When I tried to use this application I get the following warning when I get the Bean from ClassPathXMLApplicationContext object.

    I am still calling this API as part of initialization in the class object I create using the bean and have even added

    Code:
    log4j.logger.org.springframework.context.support.ClassPathXmlApplicationContext=OFF, Console
    in the log4j file.

    Code:
    log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
    log4j:WARN Please initialize the log4j system properly.

    I have tried to add
    Code:
    	<bean id="log4jInitialization"
    		class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    		<property name="targetClass" value="org.springframework.util.Log4jConfigurer" />
    		<property name="targetMethod" value="initLogging" />
    		<property name="arguments">
    			<list>
    				<value>resources/log4j.config.properties</value>
    			</list>
    		</property>
    	</bean>
    but of no use. Does anyone knows the source of the issue? and how to fix it?

  • #2
    Trying to configure log4j AFTER log4j has been loaded isn't going to work. You have to do that before you touch log4j. Spring uses logging and thus logging will already be initialized.

    Comment


    • #3
      It has already been loaded? So how to go about it? How to configure this loading before the spring? Any helpful links?

      Comment


      • #4
        I have seen so many similar posts, but no conclusive answer. Guess this is an open question..?

        Comment


        • #5
          http://firstpartners.net/kb/index.ph...iguration_File

          Both methods displayed worked for me.

          Hope it helps.

          Enrico

          Comment

          Working...
          X