GeoTools
  1. GeoTools
  2. GEOT-1545

Need a Logger subclass which redirect everything to common-logging

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.4-RC0, 2.5-M0
    • Fix Version/s: 2.4.1, 2.5-M1
    • Component/s: metadata
    • Labels:
      None

      Description

      GeoTools uses Java logging (java.util.logging package), but GeoServer need the ability to log to different frameworks. We wish (if possible) to code against Java logging API since commons-logging is not the only candidate (SLF4J is an other one), Java logging is an attempt of standard API available on every JVM (1.4+) and its API is more elaborated than commons-logging one. The proposal is:

      • Create a java.util.logging.Logger subclass, CommonLogger, that delegates everything to commons-logging, including methods like info(String) and isLoggable(Level). Some methods may not have direct match (e.g. getHandler), but they are of interest only for advanced users (and an indirect match is possible anyway with the CommonHandler already available in the GeoTools code base).
      • Switch all Logger.getLogger(xxx) methods to a special GeoTools utility class (maybe the existing Logging class) that will return either the plain java logging logger, or the CommonLogger, depending on a configuration.
      • We'll have some way to switch GeoTools logging one way or the other (and the same will have to work for GeoServer as well).

      The level matching currently used is:

      Log4J Level java.util.logging Level
      ALL FINEST
      TRACE FINER
      DEBUG FINE/CONFIG
      INFO INFO
      WARN/ERROR WARNING
      FATAL SEVERE
      OFF OFF

      CommonLogger pseudo-code:

      class CommonLogger extends Logger {
          private Log commonLog;
      
          public boolean isLoggable(Level level) {
              switch (level) {
                  case FINER: return commonLog.isTraceEnabled();
                  case FINE:  return commonLog.isDebugEnabled();
                  // etc...
              }
          }
      
          public void finer(String message) {
              commonLog.trace(message);
          }
      
          // etc...
      }
      
      1. build.xml
        1 kB
        Martin Desruisseaux
      2. modified.txt
        41 kB
        Martin Desruisseaux

        Issue Links

          Activity

          Hide
          Martin Desruisseaux added a comment -
          Commited on the 2.4 branch as of revision 27863.
          Show
          Martin Desruisseaux added a comment - Commited on the 2.4 branch as of revision 27863.
          Hide
          Jody Garnett added a comment -
          Not done yet Martin; some docs and questions need to be answered first please.

          Propsal page:
          - http://docs.codehaus.org/display/GEOTOOLS/Allow+redirection+to+alternate+logging+API

          Has a few more tasks to do...
          Show
          Jody Garnett added a comment - Not done yet Martin; some docs and questions need to be answered first please. Propsal page: - http://docs.codehaus.org/display/GEOTOOLS/Allow+redirection+to+alternate+logging+API Has a few more tasks to do...
          Hide
          Jody Garnett added a comment -
          I went to add the setLogginFactory method to GeoTools class; instead I see a very long comment in the init method. If the proposal page is not what you intend to make then we should update it ...

          Added the method; searching for a LoggingFactory to set ... seems we have two instances but they are both hidden.

          The non public nested class Factory is defined in CommonsLogger; this method has a public static synchronized Factory getInstance() method; end users obviously cannot call this code.

          This is going to be fun to document.
          Show
          Jody Garnett added a comment - I went to add the setLogginFactory method to GeoTools class; instead I see a very long comment in the init method. If the proposal page is not what you intend to make then we should update it ... Added the method; searching for a LoggingFactory to set ... seems we have two instances but they are both hidden. The non public nested class Factory is defined in CommonsLogger; this method has a public static synchronized Factory getInstance() method; end users obviously cannot call this code. This is going to be fun to document.
          Hide
          Martin Desruisseaux added a comment -
          You can kill GeoTools.init(...) if you wish. I don't use it myself. Actually I don't like it, so I will be pleased if you remove it. It was an attempt to adress some user demands, but it may cause more hurt than good.

          As for setting the logging framework, the current method call is:

          Logging.ALL.setLoggingFramework(LoggingFramework.LOG4J);

          However Andrea is suggesting to kill LoggingFramework, so it may be better to wait a little bit before to add this call.
          Show
          Martin Desruisseaux added a comment - You can kill GeoTools.init(...) if you wish. I don't use it myself. Actually I don't like it, so I will be pleased if you remove it. It was an attempt to adress some user demands, but it may cause more hurt than good. As for setting the logging framework, the current method call is: Logging.ALL.setLoggingFramework(LoggingFramework.LOG4J); However Andrea is suggesting to kill LoggingFramework, so it may be better to wait a little bit before to add this call.
          Hide
          Martin Desruisseaux added a comment -
          Developper guide updated.
          Show
          Martin Desruisseaux added a comment - Developper guide updated.

            People

            • Assignee:
              Martin Desruisseaux
              Reporter:
              Martin Desruisseaux
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: