Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8484213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:19:04+00:00 2026-06-10T20:19:04+00:00

In our application, we decided to name the log4j configuration file as a custom

  • 0

In our application, we decided to name the log4j configuration file as a custom name to avoid inadvertent loading of the default file from another jar. To configure this, we use org.springframework.util.Log4jConfigurer to specify the log4j location.

<bean
    class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetClass">
        <value>org.springframework.util.Log4jConfigurer</value>
    </property>
    <property name="targetMethod">
        <value>initLogging</value>
    </property>
    <property name="arguments">
        <list>
            <value>classpath:com/kilo/custom-log4j.xml</value>
        </list>
    </property>
</bean>

This also helps to keep all of the configuration in the code and let’s a new developer hit the ground running (rather than keeping it in some setenv.sh for the container and separately for the test cases). So far we were sufficiently happy till we discovered that some valuable logging from the Spring container itself was missed out due to this.

[ 2012-09-05 00:16:43,188 [main] support.DefaultListableBeanFactory.registerBeanDefinition():618  INFO ]: Overriding bean definition for bean 'beanA': replacing [Generic bean: class [com.kilo.spring.context.log.ClassA]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [com/kilo/spring/context/log/spring-application-context-2.xml]] with [Generic bean: class [com.kilo.spring.context.log.ClassA]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [com/kilo/spring/context/log/spring-application-context-1.xml]]
[ 2012-09-05 00:16:43,235 [main] support.DefaultListableBeanFactory.preInstantiateSingletons():555  INFO ]: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@8453227: defining beans [org.springframework.beans.factory.config.MethodInvokingFactoryBean#0,beanB,beanA]; root of factory hierarchy

If I configured the name via the system property log4j.configuration I am able to see the logs. I guess this can go away if we put the configuration as a static block in one of the classes – but in a web application, this seemed strange to do.
Any other tricks that I could use? Feel free to point out any/all incorrect paradigms that I am following here.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:19:05+00:00Added an answer on June 10, 2026 at 8:19 pm

    In Tomcat you can configure such a string in the tomcats context.xml

    <Parameter name="log4j.configuration" value="whereEver"/>
    

    An other way would be configuration via JNDI.

    BTW read this question Initializing Log4J with Spring?, it contains a link (in the comment of the accepted answer) to an implementation that configures log4j via jndi in a servlet listener.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have to introduce logging in our application. We have decided to use log4j
I am working on the I18n of our java application and we have decided
Our application takes text from a web form and sends it via email to
Our application downloads data from the internet using RSS but is having connection problems
We have to handle user specified date formats in our application. We decided to
I've been using QPlainTextEdit for editing text in our application. Recently it was decided
We decided to use gwt modules in our application about 1 week ago. We
So we've decided to rebuild an application in our business since it's been sitting
In our application, we dynamically load a dll file, which again has static bindings
To add an audit trail to our application we decided to use NHibernate.Envers. To

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.