Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0-beta-1
    • Component/s: None
    • Labels:
      None

      Description

      As a lot of web-applications use slf4j for logging, it would be nice if you could support this as a Mojo parameter, like <logging>slf4j</logging>

      This should trigger something like:
      java.util.logging.LogManager.getLogManager().reset();
      SLF4JBridgeHandler.install();

      (requires org.slf4j:jul-to-slf4j on the classpath)

        Activity

        Hide
        Hudson added a comment -

        Integrated in TomcatMavenPlugin #77 (See https://builds.apache.org/job/TomcatMavenPlugin/77/)
        MTOMCAT-110 Support Slf4j bridge logger.

        olamy : http://svn.apache.org/viewvc/?view=rev&rev=1221816
        Files :

        • /tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java
        • /tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7RunnerCli.java
        Show
        Hudson added a comment - Integrated in TomcatMavenPlugin #77 (See https://builds.apache.org/job/TomcatMavenPlugin/77/ ) MTOMCAT-110 Support Slf4j bridge logger. olamy : http://svn.apache.org/viewvc/?view=rev&rev=1221816 Files : /tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java /tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7RunnerCli.java
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        committed.
        please try last SNAPSHOT.
        note you must add various slf4j files in extraDependencies section to have those included in root class loader.

        Show
        Olivier Lamy (*$^¨%`£) added a comment - committed. please try last SNAPSHOT. note you must add various slf4j files in extraDependencies section to have those included in root class loader.
        Hide
        Morten Haraldsen added a comment - - edited

        Yes, something like:
        -logger slf4j

        Edit: Btw, no reason to not move the clazz variable inside the try/catch like final Class<?> clazz = ...

        PS: Could we have

        
        

        tags turned on?

        Show
        Morten Haraldsen added a comment - - edited Yes, something like: -logger slf4j Edit: Btw, no reason to not move the clazz variable inside the try/catch like final Class<?> clazz = ... PS: Could we have tags turned on?
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        lovely
        But from where parameter loggerName comes ? IMHO a cli option ?

        Show
        Olivier Lamy (*$^¨%`£) added a comment - lovely But from where parameter loggerName comes ? IMHO a cli option ?
        Hide
        Morten Haraldsen added a comment - - edited

        Hi again, I thought I should simplify your task a bit, and I wrote the following snippet:

        private void installLogger(String loggerName) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
        {
        if ("slf4j".equals(loggerName))
        {

        try

        { // Check class is available final Class<?> clazz = Class.forName("org.slf4j.bridge.SLF4JBridgeHandler"); // Remove all JUL handlers java.util.logging.LogManager.getLogManager().reset(); // Install slf4j bridge handler final Method method = clazz.getMethod("install", null); method.invoke(null); }

        catch (ClassNotFoundException e)

        { // TODO: Notify that the class was missing }

        }
        else

        { // TODO: Notify unsupported logger type }

        }

        Show
        Morten Haraldsen added a comment - - edited Hi again, I thought I should simplify your task a bit, and I wrote the following snippet: private void installLogger(String loggerName) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { if ("slf4j".equals(loggerName)) { try { // Check class is available final Class<?> clazz = Class.forName("org.slf4j.bridge.SLF4JBridgeHandler"); // Remove all JUL handlers java.util.logging.LogManager.getLogManager().reset(); // Install slf4j bridge handler final Method method = clazz.getMethod("install", null); method.invoke(null); } catch (ClassNotFoundException e) { // TODO: Notify that the class was missing } } else { // TODO: Notify unsupported logger type } }
        Hide
        Morten Haraldsen added a comment -

        Yes, but I think you should probably have both a flag to enable it (as shown above), and you check for class availability. I completely agree that the dependency should not be added as a requirement. Thanks for you help!

        Show
        Morten Haraldsen added a comment - Yes, but I think you should probably have both a flag to enable it (as shown above), and you check for class availability. I completely agree that the dependency should not be added as a requirement. Thanks for you help!
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        I'm not in favor about adding such dependency by default for all users (some not use slf4j).
        What I can do is to search if SLF4JBridgeHandler class is available (with a tccl.getClass() or Class.forName() ) and in such case install it.
        Makes sense for you ?

        Show
        Olivier Lamy (*$^¨%`£) added a comment - I'm not in favor about adding such dependency by default for all users (some not use slf4j). What I can do is to search if SLF4JBridgeHandler class is available (with a tccl.getClass() or Class.forName() ) and in such case install it. Makes sense for you ?
        Hide
        Morten Haraldsen added a comment -

        I use the plugin for building standalone tomcat applications, so exec-war-only goal is all that needs to be supported in my case.

        PS: I'm not that cute

        Show
        Morten Haraldsen added a comment - I use the plugin for building standalone tomcat applications, so exec-war-only goal is all that needs to be supported in my case. PS: I'm not that cute
        Hide
        Olivier Lamy (*$^¨%`£) added a comment -

        I miss you here.
        Do you need that for tomcat*:run or for the exec war ? or for both ?

        Show
        Olivier Lamy (*$^¨%`£) added a comment - I miss you here. Do you need that for tomcat*:run or for the exec war ? or for both ?

          People

          • Assignee:
            Olivier Lamy (*$^¨%`£)
            Reporter:
            Morten Haraldsen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 2h
              2h
              Remaining:
              Remaining Estimate - 2h
              2h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development