Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Dynamically changing Smart GWT log level

    I am trying to change the Smart GWT log level dynmically but to no avail. If the user changes the Loggging level in my form, on the server side I am doing the following:

    Code:
    Logger smartGwtLogger = Logger.getLogger("com.isomorphic");
           if (smartGwtLogger != null) {
                Level currentLogLevel = smartGwtLogger.getLevel();
                if (!currentLogLevel.equals(newLevel)) {
                    smartGwtLogger.setLevel(newLevel);
                }
            }
    The code gets executed OK but Smart GWT continues to log at whatever level was set in the log4j.isc.config.xml.

    Am I doing something wrong? The above approach works fine for our own logging.
    Last edited by stonebranch1; 10 May 2014, 11:55.

    #2
    Is anybody else changing the Smart GWT logging level dynamically? If so how?

    Comment


      #3
      Still curious if I can dynamically change the SmartGWT server-side log level while running. We provide some configuration properties that can be changed and one of them is the log level. Our log level changes OK this way but trying I am having problems trying to change the SmartGWT logger log level while running.

      Comment


        #4
        You can do this from the Developer Console's Server Logs tab.

        Comment


          #5
          Can I also do it from my java code on the server?

          Our customers can change the log level via a set of properties we expose to the UI. We do not expose the Developer Console in production to our customers so they cannot change it that way.

          Comment


            #6
            You can via direct use of Log4j. The capability of doing this isn't specially wrapped via our Logger class (the API you found has a different purpose).

            Comment


              #7
              That code was using Log4j but it doesn't work for me. I basically need to do the same thing you do via the Developers Console.

              The consoles ends up making a DMI builtin call to "setLogThreshold" I see.

              Can I call your method (or some other method) from the server to basically achieve the same thing?

              If not would it be possible to find out what that method ("setLogThreshold") actually does so I can do the same thing?

              Comment


                #8
                You can get access to org.apache.log4j.spi.LoggerRepository via:
                Code:
                LoggerRepository repository = com.isomorphic.log.Logger.getLoggerRepository();
                and from there use log4j API:
                Code:
                repository.getLogger(category).setLevel(newLevel);

                Comment


                  #9
                  Will do. Thanks.

                  Comment


                    #10
                    Is that 1st line of code correct?

                    I tried it as it is and get the following error:

                    "The method getLoggerRepository() is undefined for the type Logger"

                    and when I look at the "com.isomorphic.log.Logger" class I do not see the method "getLoggerRepository"

                    Code level: SmartClient Version: v9.1p_2014-05-15/Pro Deployment (built 2014-05-15)

                    Comment


                      #11
                      Suggested code would work since 10.0 version of Smartclient.

                      For 9.1 version you can do the following:
                      Code:
                      org.apache.log4j.Hierarchy hierarchy = com.isomorphic.log.Logger.getHierarchy();
                      hierarchy.getLogger(category).setLevel(newLevel);

                      Comment


                        #12
                        Excellent, that did the trick. Thank you kindly.

                        Comment

                        Working...
                        X