Results 1 to 2 of 2

Thread: Logging best practices?

  1. #1
    Join Date
    Aug 2004
    Posts
    7

    Default Logging best practices?

    Hi,
    Can someone provide advice or best practice for this problem? We use the Spring framework (v1.0) and have the following setup in our web.xml to initiate logging

    <context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/conf/log4j.properties</param-value>
    </context-param>

    This is fine and has been working for us. However, now we are moving into managed regions, which equate to a test, qa and prod regions. The problem now becomes a question of managing the logging level depending on what region we are in.

    We do not have the ability to change the application property files once it moves into Test and all files from Test get moved up to QA. All files from QA eventually move up to Prod. So, as you can see, if we turn on logging in Test, then that logging will be on in Prod, which we do not want.

    We know what region we are in because we start the application server up with a System property that we can access. This tells us what region we are in. So we are thinking we will have 4 versions of the log4j.properties file, with the following directory structure

    /WEB-INF/conf/dev/log4j.properties
    /WEB-INF/conf/test/log4j.properties
    /WEB-INF/conf/qa/log4j.properties
    /WEB-INF/conf/prod/log4j.properties

    Is this the correct approach? I presume I will have to customize org.springframework.web.util.Log4jConfigServlet. I'm interested in your thoughts.

    Thanks.

  2. #2
    Join Date
    Aug 2004
    Location
    Auburn, AL, USA.
    Posts
    106

    Default

    I think that log4j also allows system property substitution in its properties files so you could have something like:

    Code:
    log4j.rootCategory=$&#123;region.logLevel&#125;, A1
    And then set region.logLevel as a system property.

    I am not an expert on log4j, but I am pretty sure that the code above will work. If you have more questions you might try signing up to the log4j list as they may be able to provide more help.

Similar Threads

  1. Logging during testing
    By mariuss in forum Container
    Replies: 5
    Last Post: Jul 26th, 2005, 12:45 AM
  2. Newbie question: How to get spring debug logging on?
    By wangjammer5 in forum Container
    Replies: 2
    Last Post: Jul 15th, 2005, 07:11 AM
  3. Log4j, Commons Logging in JRun 4 problem
    By virgo_ct in forum Container
    Replies: 4
    Last Post: Jul 13th, 2005, 04:17 AM
  4. Setting logging level to Debug in Spring
    By fineman in forum Container
    Replies: 2
    Last Post: Jul 8th, 2005, 09:31 AM
  5. Replies: 29
    Last Post: Apr 12th, 2005, 05:24 PM

Posting Permissions

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