ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [04/24] incubator-ignite git commit: # ignite-788: another methods
Date Mon, 20 Jul 2015 14:55:07 GMT
# ignite-788: another methods


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/81c8eea9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/81c8eea9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/81c8eea9

Branch: refs/heads/ignite-788-last-review
Commit: 81c8eea90ac893b277db003a905c877a80ef05a3
Parents: d7f3588
Author: ashutak <ashutak@gridgain.com>
Authored: Tue Jul 14 19:43:58 2015 +0300
Committer: ashutak <ashutak@gridgain.com>
Committed: Tue Jul 14 19:43:58 2015 +0300

----------------------------------------------------------------------
 .../ignite/logger/log4j2/Log4J2Logger.java      | 40 +++++++++++++++++---
 1 file changed, 34 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/81c8eea9/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index 45898ad..5fd4e5d 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -258,14 +258,38 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware,
Log4jFileA
      * @param level Log level to set.
      */
     public void setLevel(Level level) {
-        impl.setLevel(level);
+        LoggerContext ctx = (LoggerContext)LogManager.getContext(false);
+
+        Configuration conf = ctx.getConfiguration();
+
+        conf.getLoggerConfig(impl.getName()).setLevel(level);
+
+        ctx.updateLoggers(conf);
     }
 
     /** {@inheritDoc} */
     @Nullable @Override public String fileName() {
-        FileAppender fapp = F.first(fileAppenders);
+        // TODO
+        // It was.
+//        FileAppender fapp = F.first(fileAppenders);
+//
+//        return fapp != null ? fapp.getFile() : null;
+
+        // New logic.
+        // TODO cast, RollingFileAppender and etc.
+        org.apache.logging.log4j.core.Logger logImpl = (org.apache.logging.log4j.core.Logger)impl;
+
+        Collection<Appender> appenders = logImpl.getAppenders().values();
 
-        return fapp != null ? fapp.getFile() : null;
+        for (Appender a : appenders) {
+            if (a instanceof FileAppender)
+                return ((FileAppender)a).getFileName();
+
+            if (a instanceof RollingFileAppender)
+                return ((RollingFileAppender)a).getFileName();
+        }
+
+        return null;
     }
 
     /**
@@ -443,9 +467,13 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware,
Log4jFileA
      * @return {@link IgniteLogger} wrapper around log4j logger.
      */
     @Override public Log4J2Logger getLogger(Object ctgr) {
-        return new Log4J2Logger(ctgr == null ? Logger.getRootLogger() :
-            ctgr instanceof Class ? Logger.getLogger(((Class<?>)ctgr).getName()) :
-                Logger.getLogger(ctgr.toString()));
+        if (ctgr == null)
+            return new Log4J2Logger(LogManager.getRootLogger());
+
+        if (ctgr instanceof Class)
+            return new Log4J2Logger(LogManager.getLogger(((Class<?>)ctgr).getName()));
+
+        return new Log4J2Logger(LogManager.getLogger(ctgr.toString()));
     }
 
     /** {@inheritDoc} */


Mime
View raw message