3 Replies Latest reply on Dec 12, 2007 12:02 PM by barthjj

    Programmatic Log4j Configuration

    barthjj

      Can anyone help me use programmatic log4j configuration in a Seam application? I want to continue to use the @Logger, because that's sweet, but I need configurations to vary between DEV, TEST, PROD.

        • 1. Re: Programmatic Log4j Configuration
          barthjj

          Looks like nobody cares about this. I'll respond with my results so far anyway.

          I've setup a component as:

          @Name("configLogger")
          @Scope(value = ScopeType.APPLICATION)
          @Startup
          public class ConfigLog4j {
          
           @Create
           public void configureLogger() {
           URL url = new URL("file:///log4j.xml");
           PropertyConfigurator.configure(url);
           }
          }
          


          I've setup the log4j.xml that is packaged with the war to be priority value="INFO". I made the external log4j.xml set priority value="DEBUG". I'm expecting that after the above code is run, all of the logs should switch to DEBUG, but nothing is changing.

          Any help?

          • 2. Re: Programmatic Log4j Configuration
            atao
            • 3. Re: Programmatic Log4j Configuration
              barthjj

              Thanks for the link. I looked at the code there and found out what my problem was. I was using PropertyConfigurator instead of DOMConfigurator. Here's the working code

              @Name("configLogger")
              @Startup
              @Scope(APPLICATION)
              public class ConfigLog4j{
              
               @Create
               public void init() {
               DOMConfigurator.configure("c:/log4j.xml");
               }
              }