openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1765691 - in /openwebbeans/microwave/trunk: microwave-core/ microwave-core/src/main/java/org/apache/microwave/ microwave-core/src/main/java/org/apache/microwave/logging/ microwave-core/src/main/java/org/apache/microwave/logging/jul/ microw...
Date Wed, 19 Oct 2016 17:55:47 GMT
Author: rmannibucau
Date: Wed Oct 19 17:55:46 2016
New Revision: 1765691

URL: http://svn.apache.org/viewvc?rev=1765691&view=rev
Log:
using log4j2

Added:
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/jul/
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/jul/Log4j2Logger.java
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/openwebbeans/
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/openwebbeans/Log4j2LoggerFactory.java
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/JULLog.java
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/Log4j2Log.java
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/LogFacade.java
    openwebbeans/microwave/trunk/microwave-core/src/main/resources/META-INF/services/
    openwebbeans/microwave/trunk/microwave-core/src/main/resources/META-INF/services/org.apache.juli.logging.Log
    openwebbeans/microwave/trunk/microwave-core/src/main/resources/log4j2.xml
Modified:
    openwebbeans/microwave/trunk/microwave-core/pom.xml
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
    openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveExtension.java
    openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveTask.java
    openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java

Modified: openwebbeans/microwave/trunk/microwave-core/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/pom.xml?rev=1765691&r1=1765690&r2=1765691&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/pom.xml (original)
+++ openwebbeans/microwave/trunk/microwave-core/pom.xml Wed Oct 19 17:55:46 2016
@@ -37,6 +37,7 @@
     <tomcat.version>8.5.6</tomcat.version>
     <cxf.version>3.1.9-SNAPSHOT</cxf.version>
     <johnzon.version>0.9.5</johnzon.version>
+    <log4j2.version>2.7</log4j2.version>
   </properties>
 
   <dependencies>
@@ -162,6 +163,17 @@
     </dependency>
 
     <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <version>${log4j2.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <version>${log4j2.version}</version>
+    </dependency>
+
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>${junit.version}</version>

Modified: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java?rev=1765691&r1=1765690&r2=1765691&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
Wed Oct 19 17:55:46 2016
@@ -41,6 +41,9 @@ import org.apache.commons.lang3.text.Str
 import org.apache.coyote.http2.Http2Protocol;
 import org.apache.cxf.helpers.FileUtils;
 import org.apache.microwave.cxf.CxfCdiAutoSetup;
+import org.apache.microwave.logging.jul.Log4j2Logger;
+import org.apache.microwave.logging.openwebbeans.Log4j2LoggerFactory;
+import org.apache.microwave.logging.tomcat.Log4j2Log;
 import org.apache.microwave.openwebbeans.OWBAutoSetup;
 import org.apache.microwave.runner.cli.CliOption;
 import org.apache.microwave.tomcat.ProvidedLoader;
@@ -86,6 +89,7 @@ public class Microwave implements AutoCl
 
     // we can undeploy webapps with that later
     private final Map<String, Context> contexts = new HashMap<>();
+    private Runnable postTask;
 
     public Microwave(final Builder builder) {
         this.configuration = builder;
@@ -183,6 +187,33 @@ public class Microwave implements AutoCl
     }
 
     public Microwave start() {
+        if (configuration.loggingGlobalSetup) {
+            final String[] toRestore = new String[]{
+                    System.getProperty("openwebbeans.logging.factory"),
+                    System.getProperty("org.apache.cxf.Logger"),
+                    System.getProperty("org.apache.tomcat.Logger")
+            };
+            System.setProperty("openwebbeans.logging.factory", Log4j2LoggerFactory.class.getName());
+            System.setProperty("org.apache.cxf.Logger", Log4j2Logger.class.getName());
+            System.setProperty("org.apache.tomcat.Logger", Log4j2Log.class.getName());
+            postTask = () -> {
+                if (toRestore[0] == null) {
+                    System.clearProperty("openwebbeans.logging.factory");
+                } else {
+                    System.setProperty("openwebbeans.logging.factory", toRestore[0]);
+                }
+                if (toRestore[1] == null) {
+                    System.clearProperty("org.apache.cxf.Logger");
+                } else {
+                    System.setProperty("org.apache.cxf.Logger", toRestore[1]);
+                }
+                if (toRestore[2] == null) {
+                    System.clearProperty("org.apache.tomcat.Logger");
+                } else {
+                    System.setProperty("org.apache.tomcat.Logger", toRestore[2]);
+                }
+            };
+        }
         if (configuration.quickSession) {
             tomcat = new TomcatWithFastSessionIDs();
         } else {
@@ -287,7 +318,7 @@ public class Microwave implements AutoCl
                 host.setWorkDir(new File(base, "work").getAbsolutePath());
             }
             tomcat.setHost(host);
-            tomcat.getEngine().addChild( host );
+            tomcat.getEngine().addChild(host);
         }
 
         if (configuration.realm != null) {
@@ -394,6 +425,8 @@ public class Microwave implements AutoCl
         } catch (final LifecycleException e) {
             throw new IllegalStateException(e);
         } finally {
+            ofNullable(postTask).ifPresent(Runnable::run);
+            postTask = null;
             FileUtils.delete(base);
         }
     }
@@ -611,10 +644,21 @@ public class Microwave implements AutoCl
         @CliOption(name = "jaxrs-provider-setup", description = "Should default JAX-RS provider
be configured")
         private boolean jaxrsProviderSetup = true;
 
+        @CliOption(name = "logging-global-setup", description = "Should logging be configured
to use log4j2 (it is global)")
+        private boolean loggingGlobalSetup = true;
+
         public Builder() { // load defaults
             loadFrom("microwave.properties");
         }
 
+        public boolean isLoggingGlobalSetup() {
+            return loggingGlobalSetup;
+        }
+
+        public void setLoggingGlobalSetup(final boolean loggingGlobalSetup) {
+            this.loggingGlobalSetup = loggingGlobalSetup;
+        }
+
         public boolean isJaxrsProviderSetup() {
             return jaxrsProviderSetup;
         }

Added: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/jul/Log4j2Logger.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/jul/Log4j2Logger.java?rev=1765691&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/jul/Log4j2Logger.java
(added)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/jul/Log4j2Logger.java
Wed Oct 19 17:55:46 2016
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.microwave.logging.jul;
+
+import org.apache.cxf.common.logging.AbstractDelegatingLogger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.simple.SimpleLogger;
+import org.apache.logging.log4j.status.StatusLogger;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+public class Log4j2Logger extends AbstractDelegatingLogger {
+    private static final Map<Level, org.apache.logging.log4j.Level> TO_LOG4J = new
HashMap<>();
+
+    private final Logger log;
+
+    static {
+        //older versions of log4j don't have TRACE, use debug
+        org.apache.logging.log4j.Level t = org.apache.logging.log4j.Level.DEBUG;
+
+        TO_LOG4J.put(Level.ALL, org.apache.logging.log4j.Level.ALL);
+        TO_LOG4J.put(Level.SEVERE, org.apache.logging.log4j.Level.ERROR);
+        TO_LOG4J.put(Level.WARNING, org.apache.logging.log4j.Level.WARN);
+        TO_LOG4J.put(Level.INFO, org.apache.logging.log4j.Level.INFO);
+        TO_LOG4J.put(Level.CONFIG, org.apache.logging.log4j.Level.DEBUG);
+        TO_LOG4J.put(Level.FINE, org.apache.logging.log4j.Level.DEBUG);
+        TO_LOG4J.put(Level.FINER, org.apache.logging.log4j.Level.TRACE);
+        TO_LOG4J.put(Level.FINEST, org.apache.logging.log4j.Level.TRACE);
+        TO_LOG4J.put(Level.OFF, org.apache.logging.log4j.Level.OFF);
+    }
+
+    public Log4j2Logger(final String name, final String resourceBundleName) {
+        super(name, resourceBundleName);
+        log = LogManager.getLogger(name);
+    }
+
+    @Override
+    public void setLevel(final Level newLevel) throws SecurityException {
+        if (org.apache.logging.log4j.core.Logger.class.isInstance(log)) {
+            org.apache.logging.log4j.core.Logger.class.cast(log).setLevel(TO_LOG4J.get(newLevel));
+        } else if (StatusLogger.class.isInstance(log)) {
+            StatusLogger.class.cast(log).setLevel(TO_LOG4J.get(newLevel));
+        } else if (SimpleLogger.class.isInstance(log)) {
+            SimpleLogger.class.cast(log).setLevel(TO_LOG4J.get(newLevel));
+        } // else ExtendedLoggerWrapper: ignore for now. we could do reflection if we need
it
+    }
+
+    public Level getLevel() {
+        final org.apache.logging.log4j.Level l = log.getLevel();
+        if (l != null) {
+            return fromL4J(l);
+        }
+        return null;
+    }
+
+    protected void internalLogFormatted(final String msg, final LogRecord record) {
+        log.log(TO_LOG4J.get(record.getLevel()), msg, record.getThrown());
+    }
+
+
+    private Level fromL4J(final org.apache.logging.log4j.Level l) {
+        Level l2 = null;
+        switch (l.getStandardLevel()) {
+            case ALL:
+                l2 = Level.ALL;
+                break;
+            case FATAL:
+                l2 = Level.SEVERE;
+                break;
+            case ERROR:
+                l2 = Level.SEVERE;
+                break;
+            case WARN:
+                l2 = Level.WARNING;
+                break;
+            case INFO:
+                l2 = Level.INFO;
+                break;
+            case DEBUG:
+                l2 = Level.FINE;
+                break;
+            case OFF:
+                l2 = Level.OFF;
+                break;
+            case TRACE:
+                l2 = Level.FINEST;
+                break;
+            default:
+                l2 = Level.FINE;
+        }
+        return l2;
+    }
+}

Added: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/openwebbeans/Log4j2LoggerFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/openwebbeans/Log4j2LoggerFactory.java?rev=1765691&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/openwebbeans/Log4j2LoggerFactory.java
(added)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/openwebbeans/Log4j2LoggerFactory.java
Wed Oct 19 17:55:46 2016
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.microwave.logging.openwebbeans;
+
+import org.apache.microwave.logging.jul.Log4j2Logger;
+import org.apache.webbeans.logger.WebBeansLoggerFactory;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
+
+public class Log4j2LoggerFactory implements WebBeansLoggerFactory {
+    @Override
+    public Logger getLogger(final Class<?> clazz, final Locale desiredLocale) {
+        return new Log4j2Logger(clazz.getName(), ResourceBundle.getBundle("openwebbeans/Messages",
desiredLocale).toString());
+    }
+
+    @Override
+    public Logger getLogger(final Class<?> clazz) {
+        return new Log4j2Logger(clazz.getName(), "openwebbeans/Messages");
+    }
+}

Added: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/JULLog.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/JULLog.java?rev=1765691&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/JULLog.java
(added)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/JULLog.java
Wed Oct 19 17:55:46 2016
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.microwave.logging.tomcat;
+
+import org.apache.juli.logging.Log;
+
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Formatter;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+// copied from tomcat to allow our routing logic
+public class JULLog implements Log {
+    private final Logger logger;
+
+    private static final String SIMPLE_FMT = "java.util.logging.SimpleFormatter";
+    private static final String SIMPLE_CFG = "org.apache.juli.JdkLoggerConfig"; //doesn't
exist
+    private static final String FORMATTER = "org.apache.juli.formatter";
+
+    static {
+        if (System.getProperty("java.util.logging.config.class") == null &&
+                System.getProperty("java.util.logging.config.file") == null) {
+            try {
+                Class.forName(SIMPLE_CFG).newInstance();
+            } catch (final Throwable t) {
+                // no-op
+            }
+            try {
+                final Formatter fmt = (Formatter) Class.forName(System.getProperty(FORMATTER,
SIMPLE_FMT)).newInstance();
+                Logger root = Logger.getLogger("");
+                for (Handler handler : root.getHandlers()) {
+                    if (handler instanceof ConsoleHandler) {
+                        handler.setFormatter(fmt);
+                    }
+                }
+            } catch (final Throwable t) {
+                // maybe it wasn't included - the ugly default will be used.
+            }
+
+        }
+    }
+
+    public JULLog(final String name) {
+        logger = Logger.getLogger(name);
+    }
+
+    @Override
+    public final boolean isErrorEnabled() {
+        return logger.isLoggable(Level.SEVERE);
+    }
+
+    @Override
+    public final boolean isWarnEnabled() {
+        return logger.isLoggable(Level.WARNING);
+    }
+
+    @Override
+    public final boolean isInfoEnabled() {
+        return logger.isLoggable(Level.INFO);
+    }
+
+    @Override
+    public final boolean isDebugEnabled() {
+        return logger.isLoggable(Level.FINE);
+    }
+
+    @Override
+    public final boolean isFatalEnabled() {
+        return logger.isLoggable(Level.SEVERE);
+    }
+
+    @Override
+    public final boolean isTraceEnabled() {
+        return logger.isLoggable(Level.FINER);
+    }
+
+    @Override
+    public final void debug(final Object message) {
+        log(Level.FINE, String.valueOf(message), null);
+    }
+
+    @Override
+    public final void debug(final Object message, final Throwable t) {
+        log(Level.FINE, String.valueOf(message), t);
+    }
+
+    @Override
+    public final void trace(final Object message) {
+        log(Level.FINER, String.valueOf(message), null);
+    }
+
+    @Override
+    public final void trace(final Object message, final Throwable t) {
+        log(Level.FINER, String.valueOf(message), t);
+    }
+
+    @Override
+    public final void info(final Object message) {
+        log(Level.INFO, String.valueOf(message), null);
+    }
+
+    @Override
+    public final void info(final Object message, final Throwable t) {
+        log(Level.INFO, String.valueOf(message), t);
+    }
+
+    @Override
+    public final void warn(final Object message) {
+        log(Level.WARNING, String.valueOf(message), null);
+    }
+
+    @Override
+    public final void warn(final Object message, final Throwable t) {
+        log(Level.WARNING, String.valueOf(message), t);
+    }
+
+    @Override
+    public final void error(final Object message) {
+        log(Level.SEVERE, String.valueOf(message), null);
+    }
+
+    @Override
+    public final void error(final Object message, final Throwable t) {
+        log(Level.SEVERE, String.valueOf(message), t);
+    }
+
+    @Override
+    public final void fatal(final Object message) {
+        log(Level.SEVERE, String.valueOf(message), null);
+    }
+
+    @Override
+    public final void fatal(final Object message, final Throwable t) {
+        log(Level.SEVERE, String.valueOf(message), t);
+    }
+
+    // from commons logging. This would be my number one reason why java.util.logging
+    // is bad - design by committee can be really bad ! The impact on performance of
+    // using java.util.logging - and the ugliness if you need to wrap it - is far
+    // worse than the unfriendly and uncommon default format for logs.
+
+    private void log(final Level level, final String msg, final Throwable ex) {
+        if (logger.isLoggable(level)) {
+            // Hack (?) to get the stack trace.
+            Throwable dummyException = new Throwable();
+            StackTraceElement locations[] = dummyException.getStackTrace();
+            // Caller will be the third element
+            String cname = "unknown";
+            String method = "unknown";
+            if (locations != null && locations.length > 2) {
+                StackTraceElement caller = locations[2];
+                cname = caller.getClassName();
+                method = caller.getMethodName();
+            }
+            if (ex == null) {
+                logger.logp(level, cname, method, msg);
+            } else {
+                logger.logp(level, cname, method, msg, ex);
+            }
+        }
+    }
+}

Added: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/Log4j2Log.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/Log4j2Log.java?rev=1765691&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/Log4j2Log.java
(added)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/Log4j2Log.java
Wed Oct 19 17:55:46 2016
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.microwave.logging.tomcat;
+
+import org.apache.juli.logging.Log;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class Log4j2Log implements Log {
+    private final Logger delegate;
+
+    public Log4j2Log(final String name) {
+        delegate = LogManager.getLogger(name);
+    }
+
+    @Override
+    public boolean isDebugEnabled() {
+        return delegate.isDebugEnabled();
+    }
+
+    @Override
+    public boolean isErrorEnabled() {
+        return delegate.isErrorEnabled();
+    }
+
+    @Override
+    public boolean isFatalEnabled() {
+        return delegate.isFatalEnabled();
+    }
+
+    @Override
+    public boolean isInfoEnabled() {
+        return delegate.isInfoEnabled();
+    }
+
+    @Override
+    public boolean isTraceEnabled() {
+        return delegate.isTraceEnabled();
+    }
+
+    @Override
+    public boolean isWarnEnabled() {
+        return delegate.isWarnEnabled();
+    }
+
+    @Override
+    public void trace(final Object message) {
+        delegate.trace(message);
+    }
+
+    @Override
+    public void trace(final Object message, final Throwable t) {
+        delegate.trace(message, t);
+    }
+
+    @Override
+    public void debug(final Object message) {
+        delegate.debug(message);
+    }
+
+    @Override
+    public void debug(final Object message, final Throwable t) {
+        delegate.debug(message, t);
+    }
+
+    @Override
+    public void info(final Object message) {
+        delegate.info(message);
+    }
+
+    @Override
+    public void info(final Object message, final Throwable t) {
+        delegate.info(message, t);
+    }
+
+    @Override
+    public void warn(final Object message) {
+        delegate.warn(message);
+    }
+
+    @Override
+    public void warn(final Object message, final Throwable t) {
+        delegate.warn(message, t);
+    }
+
+    @Override
+    public void error(final Object message) {
+        delegate.error(message);
+    }
+
+    @Override
+    public void error(final Object message, final Throwable t) {
+        delegate.error(message, t);
+    }
+
+    @Override
+    public void fatal(final Object message) {
+        delegate.fatal(message);
+    }
+
+    @Override
+    public void fatal(final Object message, final Throwable t) {
+        delegate.fatal(message, t);
+    }
+}

Added: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/LogFacade.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/LogFacade.java?rev=1765691&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/LogFacade.java
(added)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/logging/tomcat/LogFacade.java
Wed Oct 19 17:55:46 2016
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.microwave.logging.tomcat;
+
+import org.apache.juli.logging.Log;
+
+public class LogFacade implements Log {
+    private final Log delegate;
+
+    public LogFacade() { // for the spi
+        this.delegate = null;
+    }
+
+    public LogFacade(final String name) {
+        // should be read per launch and not once per JVM
+        this.delegate = "org.apache.microwave.logging.tomcat.Log4j2Log".equals(System.getProperty("org.apache.tomcat.Logger",
"jul")) ?
+                new Log4j2Log(name) : new JULLog(name);
+    }
+
+    @Override
+    public boolean isDebugEnabled() {
+        return delegate.isDebugEnabled();
+    }
+
+    @Override
+    public boolean isErrorEnabled() {
+        return delegate.isErrorEnabled();
+    }
+
+    @Override
+    public boolean isFatalEnabled() {
+        return delegate.isFatalEnabled();
+    }
+
+    @Override
+    public boolean isInfoEnabled() {
+        return delegate.isInfoEnabled();
+    }
+
+    @Override
+    public boolean isTraceEnabled() {
+        return delegate.isTraceEnabled();
+    }
+
+    @Override
+    public boolean isWarnEnabled() {
+        return delegate.isWarnEnabled();
+    }
+
+    @Override
+    public void trace(final Object message) {
+        delegate.trace(message);
+    }
+
+    @Override
+    public void trace(final Object message, final Throwable t) {
+        delegate.trace(message, t);
+    }
+
+    @Override
+    public void debug(final Object message) {
+        delegate.debug(message);
+    }
+
+    @Override
+    public void debug(final Object message, final Throwable t) {
+        delegate.debug(message, t);
+    }
+
+    @Override
+    public void info(final Object message) {
+        delegate.info(message);
+    }
+
+    @Override
+    public void info(final Object message, final Throwable t) {
+        delegate.info(message, t);
+    }
+
+    @Override
+    public void warn(final Object message) {
+        delegate.warn(message);
+    }
+
+    @Override
+    public void warn(final Object message, final Throwable t) {
+        delegate.warn(message, t);
+    }
+
+    @Override
+    public void error(final Object message) {
+        delegate.error(message);
+    }
+
+    @Override
+    public void error(final Object message, final Throwable t) {
+        delegate.error(message, t);
+    }
+
+    @Override
+    public void fatal(final Object message) {
+        delegate.fatal(message);
+    }
+
+    @Override
+    public void fatal(final Object message, final Throwable t) {
+        delegate.fatal(message, t);
+    }
+}

Added: openwebbeans/microwave/trunk/microwave-core/src/main/resources/META-INF/services/org.apache.juli.logging.Log
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/resources/META-INF/services/org.apache.juli.logging.Log?rev=1765691&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/resources/META-INF/services/org.apache.juli.logging.Log
(added)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/resources/META-INF/services/org.apache.juli.logging.Log
Wed Oct 19 17:55:46 2016
@@ -0,0 +1 @@
+org.apache.microwave.logging.tomcat.LogFacade

Added: openwebbeans/microwave/trunk/microwave-core/src/main/resources/log4j2.xml
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/resources/log4j2.xml?rev=1765691&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/resources/log4j2.xml (added)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/resources/log4j2.xml Wed Oct 19 17:55:46
2016
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<Configuration status="INFO">
+  <Appenders>
+    <Console name="Console" target="SYSTEM_OUT">
+      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+    </Console>
+  </Appenders>
+  <Loggers>
+    <Root level="INFO">
+      <AppenderRef ref="Console"/>
+    </Root>
+  </Loggers>
+</Configuration>

Modified: openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveExtension.java?rev=1765691&r1=1765690&r2=1765691&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveExtension.java
(original)
+++ openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveExtension.java
Wed Oct 19 17:55:46 2016
@@ -59,6 +59,7 @@ public class MicrowaveExtension {
     private boolean cdiConversation;
     private boolean skip;
     private boolean jaxrsProviderSetup = true;
+    private boolean loggingGlobalSetup = true;
 
     public boolean isJaxrsProviderSetup() {
         return jaxrsProviderSetup;

Modified: openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveTask.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveTask.java?rev=1765691&r1=1765690&r2=1765691&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveTask.java
(original)
+++ openwebbeans/microwave/trunk/microwave-gradle-plugin/src/main/java/org/apache/microwave/gradle/MicrowaveTask.java
Wed Oct 19 17:55:46 2016
@@ -169,6 +169,10 @@ public class MicrowaveTask extends Defau
 
     @Input
     @Optional
+    private boolean loggingGlobalSetup = true;
+
+    @Input
+    @Optional
     private boolean cdiConversation;
 
     @Input

Modified: openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java?rev=1765691&r1=1765690&r2=1765691&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java
(original)
+++ openwebbeans/microwave/trunk/microwave-maven-plugin/src/main/java/org/apache/microwave/maven/MicrowaveRunMojo.java
Wed Oct 19 17:55:46 2016
@@ -145,6 +145,9 @@ public class MicrowaveRunMojo extends Ab
     @Parameter(property = "microwave.jaxrs-provider-setup", defaultValue = "true")
     private boolean jaxrsProviderSetup;
 
+    @Parameter(property = "microwave.logging-global-setup", defaultValue = "true")
+    private boolean loggingGlobalSetup;
+
     @Parameter
     private List<String> jsCustomizers;
 



Mime
View raw message