tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: TOMEE-1861 making AsyncConsoleHandler configurable
Date Thu, 07 Jul 2016 10:20:40 GMT
Repository: tomee
Updated Branches:
  refs/heads/master f4a8864bf -> 677bdd77a


TOMEE-1861 making AsyncConsoleHandler  configurable


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/677bdd77
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/677bdd77
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/677bdd77

Branch: refs/heads/master
Commit: 677bdd77a86bb951d5aef9ed3cc6ffd58951ca13
Parents: f4a8864
Author: Romain manni-Bucau <rmannibucau@gmail.com>
Authored: Thu Jul 7 12:20:18 2016 +0200
Committer: Romain manni-Bucau <rmannibucau@gmail.com>
Committed: Thu Jul 7 12:20:18 2016 +0200

----------------------------------------------------------------------
 .../jul/formatter/AsyncConsoleHandler.java      | 34 ++++++++++++++++++++
 1 file changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/677bdd77/tomee/tomee-juli/src/main/java/org/apache/tomee/jul/formatter/AsyncConsoleHandler.java
----------------------------------------------------------------------
diff --git a/tomee/tomee-juli/src/main/java/org/apache/tomee/jul/formatter/AsyncConsoleHandler.java
b/tomee/tomee-juli/src/main/java/org/apache/tomee/jul/formatter/AsyncConsoleHandler.java
index 20b4d60..5fd905d 100644
--- a/tomee/tomee-juli/src/main/java/org/apache/tomee/jul/formatter/AsyncConsoleHandler.java
+++ b/tomee/tomee-juli/src/main/java/org/apache/tomee/jul/formatter/AsyncConsoleHandler.java
@@ -21,7 +21,10 @@ import org.apache.juli.AsyncFileHandler;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.logging.ConsoleHandler;
+import java.util.logging.Filter;
 import java.util.logging.Formatter;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
 import java.util.logging.LogRecord;
 
 public class AsyncConsoleHandler extends AsyncFileHandler {
@@ -33,6 +36,37 @@ public class AsyncConsoleHandler extends AsyncFileHandler {
         delegate.publish(record);
     }
 
+    public AsyncConsoleHandler() {
+        LogManager manager = LogManager.getLogManager();
+        String cname = getClass().getName();
+
+        final String lvl = manager.getProperty(cname + ".level");
+        if (lvl != null) {
+            delegate.setLevel(Level.parse(lvl));
+        }
+        final String filter = manager.getProperty(cname + ".filter");
+        if (filter != null) {
+            try {
+                delegate.setFilter(Filter.class.cast(ClassLoader.getSystemClassLoader().loadClass(filter).newInstance()));
+            } catch (final InstantiationException | IllegalAccessException | ClassNotFoundException
e) {
+                // no-op like delegate
+            }
+        }
+        final String formatter = manager.getProperty(cname + ".formatter");
+        if (formatter != null) {
+            try {
+                delegate.setFormatter(Formatter.class.cast(ClassLoader.getSystemClassLoader().loadClass(formatter).newInstance()));
+            } catch (final InstantiationException | IllegalAccessException | ClassNotFoundException
e) {
+                // no-op like delegate
+            }
+        }
+        try {
+            delegate.setEncoding(manager.getProperty(cname +".encoding"));
+        } catch (final Exception ex) {
+            // no-op
+        }
+    }
+
     @Override
     public void close() {
         delegate.close();


Mime
View raw message