Results 1 to 5 of 5

Thread: Log4j configuration setting.

  1. #1
    Join Date
    Jul 2010
    Location
    India
    Posts
    19

    Post 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jul 2010
    Location
    India
    Posts
    19

    Default

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

  4. #4
    Join Date
    Jul 2010
    Location
    India
    Posts
    19

    Default

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

  5. #5
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    http://firstpartners.net/kb/index.ph...iguration_File

    Both methods displayed worked for me.

    Hope it helps.

    Enrico

Tags for this Thread

Posting Permissions

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