Quantcast

groovy git commit: GROOVY-8087: bump log4j2 version (closes #497)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

groovy git commit: GROOVY-8087: bump log4j2 version (closes #497)

paulk
Repository: groovy
Updated Branches:
  refs/heads/master 3590d77c5 -> 9c576f5d5


GROOVY-8087: bump log4j2 version (closes #497)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/9c576f5d
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/9c576f5d
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/9c576f5d

Branch: refs/heads/master
Commit: 9c576f5d5ba4bcde9f6b9081bff46ba417acc6cf
Parents: 3590d77
Author: paulk <[hidden email]>
Authored: Wed Feb 15 16:17:59 2017 +1000
Committer: paulk <[hidden email]>
Committed: Thu Feb 16 13:29:42 2017 +1000

----------------------------------------------------------------------
 build.gradle                                   |  2 +-
 src/test/groovy/util/logging/Log4j2Test.groovy | 36 ++++++++++-----------
 2 files changed, 19 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/9c576f5d/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 3188905..d431b65 100644
--- a/build.gradle
+++ b/build.gradle
@@ -161,7 +161,7 @@ ext {
     jmockVersion = '1.2.0'
     logbackVersion = '1.1.7'
     log4jVersion = '1.2.17'
-    log4j2Version = '2.3' // 2.4 requires Java 7
+    log4j2Version = '2.8'
     luceneVersion = '4.7.2'
     openbeansVersion = '1.0'
     openejbVersion = '1.0'

http://git-wip-us.apache.org/repos/asf/groovy/blob/9c576f5d/src/test/groovy/util/logging/Log4j2Test.groovy
----------------------------------------------------------------------
diff --git a/src/test/groovy/util/logging/Log4j2Test.groovy b/src/test/groovy/util/logging/Log4j2Test.groovy
index db4e23d..3d7b24c 100644
--- a/src/test/groovy/util/logging/Log4j2Test.groovy
+++ b/src/test/groovy/util/logging/Log4j2Test.groovy
@@ -22,7 +22,6 @@ import java.lang.reflect.Field
 import java.lang.reflect.Modifier
 
 import org.apache.log4j.spi.Filter
-import org.apache.log4j.spi.LoggingEvent
 import org.apache.logging.log4j.LogManager
 import org.apache.logging.log4j.core.Layout
 import org.apache.logging.log4j.core.LogEvent
@@ -36,17 +35,18 @@ import java.nio.charset.Charset
 class Log4j2Test extends GroovyTestCase {
 
     class Log4j2InterceptingAppender extends AbstractAppender {
-        List<LoggingEvent> events
+        List<Map> events
         boolean isLogGuarded = true
 
         Log4j2InterceptingAppender(String name, Filter filter, Layout<String> layout){
             super(name, filter, layout)
-            this.events = new ArrayList<LoggingEvent>()
+            this.events = new ArrayList<Map>()
         }
 
         @Override
-        void append(LogEvent event) {
-            events.add(event)
+        void append(LogEvent ev) {
+            // Log4j2 re-cycles log events so extract and store the relevant info
+            events.add([level: ev.level, message: ev.message.formattedMessage])
         }
     }
 
@@ -140,17 +140,17 @@ class Log4j2Test extends GroovyTestCase {
         def events = appender.getEvents()
         assert events.size() == 6
         assert events[ind].level == Level.FATAL
-        assert events[ind].message.message == "fatal called"
+        assert events[ind].message == "fatal called"
         assert events[++ind].level == Level.ERROR
-        assert events[ind].message.message == "error called"
+        assert events[ind].message == "error called"
         assert events[++ind].level == Level.WARN
-        assert events[ind].message.message == "warn called"
+        assert events[ind].message == "warn called"
         assert events[++ind].level == Level.INFO
-        assert events[ind].message.message == "info called"
+        assert events[ind].message == "info called"
         assert events[++ind].level == Level.DEBUG
-        assert events[ind].message.message == "debug called"
+        assert events[ind].message == "debug called"
         assert events[++ind].level == Level.TRACE
-        assert events[ind].message.message == "trace called"
+        assert events[ind].message == "trace called"
     }
 
     void testLogFromStaticMethods() {
@@ -168,7 +168,7 @@ class Log4j2Test extends GroovyTestCase {
         def events = appender.getEvents()
         assert events.size() == 1
         assert events[0].level == Level.INFO
-        assert events[0].message.message == "(static) info called"
+        assert events[0].message == "(static) info called"
     }
 
     void testLogInfoForNamedLogger() {
@@ -193,17 +193,17 @@ class Log4j2Test extends GroovyTestCase {
         def events = appender.getEvents()
         assert events.size() == 6
         assert events[ind].level == Level.FATAL
-        assert events[ind].message.message == "fatal called"
+        assert events[ind].message == "fatal called"
         assert events[++ind].level == Level.ERROR
-        assert events[ind].message.message == "error called"
+        assert events[ind].message == "error called"
         assert events[++ind].level == Level.WARN
-        assert events[ind].message.message == "warn called"
+        assert events[ind].message == "warn called"
         assert events[++ind].level == Level.INFO
-        assert events[ind].message.message == "info called"
+        assert events[ind].message == "info called"
         assert events[++ind].level == Level.DEBUG
-        assert events[ind].message.message == "debug called"
+        assert events[ind].message == "debug called"
         assert events[++ind].level == Level.TRACE
-        assert events[ind].message.message == "trace called"
+        assert events[ind].message == "trace called"
     }
 
     void testLogGuard() {

Loading...