Announcement Announcement Module
No announcement yet.
Logging best practices? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Logging best practices?

    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


    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 file, with the following directory structure


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


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

    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.