4 Replies Latest reply on Feb 14, 2004 5:53 AM by pilhuhn

    need example arg for getLoggerLevel

    larrys

      The Log4JSerivice MBean has a getLoggerLevel method that takes one argument. Could someone give some example of the arg. Specifically, how do I tell it to return the level for root?

      Also, examples using setLoggerLevel would be appreciated too. How can I turn debug level on and off system wide?

      Thx.

        • 1. Re: need example arg for getLoggerLevel
          rhcp

          I dont know how to use the getLoggerLevel mehtod but there is a smarter way to configure your level attribute!

          Go to the conf/log4j.xml file and add a new category e.g. like this

          category name="myApp.myCat"
           priority value="INFO"
           appender-ref ref="CONSOLE"
          category
          


          and then init your Logger to

          Logger log= Logger.getLogger("myApp.myCat");
          


          there you are (do the same with your own appenders).

          regards,
          Uli


          • 2. Re: need example arg for getLoggerLevel
            larrys

            Thanks. But what I want to do is use the web-console to switch root logger (or some other logger) log levels at runtime. If I understand correctly, editing log4j.xml will require a restart of jboss. I want to be able to switch to DEBUG, do some debugging, and then switch back to INFO, for example.

            • 3. Re: need example arg for getLoggerLevel
              rhcp

              Hi,

              thats right modifying the log4j need a reboot. But you can init some default settings like your default level. When you like to change the level on the fly try the following:

              Logger log= Logger.getRootLogger();
              //Logger log= Logger.getLogger("myApp");
              log.setLevel(Level.DEBUG);
              ...
              log.setLevel(Level.INFO);
              
              


              regards,
              Uli

              • 4. Re: need example arg for getLoggerLevel
                pilhuhn

                Hm. On 3.2.1 and 3.2.3, Jboss picks up modifications of log4j.xml within the next 30 seconds without a reboot.