diff --git a/config/dev/log4j2.xml b/config/dev/log4j2.xml
index 408d9574d5..17ae160b02 100644
--- a/config/dev/log4j2.xml
+++ b/config/dev/log4j2.xml
@@ -35,7 +35,7 @@
-
@@ -71,29 +71,44 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/node/src/main/resources/log4j2.component.properties b/node/src/main/resources/log4j2.component.properties
index 40a6560d2f..1b55982139 100644
--- a/node/src/main/resources/log4j2.component.properties
+++ b/node/src/main/resources/log4j2.component.properties
@@ -1,2 +1,2 @@
-log4jContextSelector=net.corda.node.utilities.logging.AsyncLoggerContextSelectorNoThreadLocal
+Log4jContextSelector=net.corda.node.utilities.logging.AsyncLoggerContextSelectorNoThreadLocal
AsyncLogger.RingBufferSize=262144
\ No newline at end of file
diff --git a/node/src/test/kotlin/net/corda/node/utilities/logging/AsyncLoggingTest.kt b/node/src/test/kotlin/net/corda/node/utilities/logging/AsyncLoggingTest.kt
new file mode 100644
index 0000000000..351760d811
--- /dev/null
+++ b/node/src/test/kotlin/net/corda/node/utilities/logging/AsyncLoggingTest.kt
@@ -0,0 +1,12 @@
+package net.corda.node.utilities.logging
+
+import org.junit.Test
+import kotlin.test.assertTrue
+
+
+class AsyncLoggingTest {
+ @Test
+ fun `async logging is configured`() {
+ assertTrue(AsyncLoggerContextSelectorNoThreadLocal.isSelected())
+ }
+}
\ No newline at end of file
diff --git a/testing/test-common/src/main/resources/log4j2-test.xml b/testing/test-common/src/main/resources/log4j2-test.xml
index 0d4feace63..221a56127b 100644
--- a/testing/test-common/src/main/resources/log4j2-test.xml
+++ b/testing/test-common/src/main/resources/log4j2-test.xml
@@ -1,5 +1,5 @@
-
+
${sys:log-path:-logs}
@@ -37,7 +37,7 @@
-
@@ -59,32 +59,47 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/tools/cliutils/src/main/kotlin/net/corda/cliutils/CordaLog4j2ConfigFactory.kt b/tools/cliutils/src/main/kotlin/net/corda/cliutils/CordaLog4j2ConfigFactory.kt
deleted file mode 100644
index 2f0931d9ba..0000000000
--- a/tools/cliutils/src/main/kotlin/net/corda/cliutils/CordaLog4j2ConfigFactory.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-package net.corda.cliutils
-
-import org.apache.logging.log4j.core.LoggerContext
-import org.apache.logging.log4j.core.config.Configuration
-import org.apache.logging.log4j.core.config.ConfigurationFactory
-import org.apache.logging.log4j.core.config.ConfigurationSource
-import org.apache.logging.log4j.core.config.Order
-import org.apache.logging.log4j.core.config.plugins.Plugin
-import org.apache.logging.log4j.core.config.xml.XmlConfiguration
-import org.apache.logging.log4j.core.impl.LogEventFactory
-
-@Plugin(name = "CordaLog4j2ConfigFactory", category = "ConfigurationFactory")
-@Order(Integer.MAX_VALUE)
-class CordaLog4j2ConfigFactory : ConfigurationFactory() {
- private companion object {
- private val SUPPORTED_TYPES = arrayOf(".xml", "*")
- }
-
- override fun getConfiguration(loggerContext: LoggerContext, source: ConfigurationSource): Configuration = ErrorCodeAppendingConfiguration(loggerContext, source)
-
- override fun getSupportedTypes() = SUPPORTED_TYPES
-
- private class ErrorCodeAppendingConfiguration(loggerContext: LoggerContext, source: ConfigurationSource) : XmlConfiguration(loggerContext, source) {
- override fun doConfigure() {
- super.doConfigure()
- loggers.values.forEach {
- val existingFactory = it.logEventFactory
- it.logEventFactory = LogEventFactory { loggerName, marker, fqcn, level, message, properties, error ->
- existingFactory.createEvent(loggerName, marker, fqcn, level, message?.withErrorCodeFor(error, level), properties, error)
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/tools/cliutils/src/main/kotlin/net/corda/cliutils/ErrorCodeRewritePolicy.kt b/tools/cliutils/src/main/kotlin/net/corda/cliutils/ErrorCodeRewritePolicy.kt
new file mode 100644
index 0000000000..dc35739ea7
--- /dev/null
+++ b/tools/cliutils/src/main/kotlin/net/corda/cliutils/ErrorCodeRewritePolicy.kt
@@ -0,0 +1,28 @@
+package net.corda.cliutils
+
+import org.apache.logging.log4j.core.Core
+import org.apache.logging.log4j.core.LogEvent
+import org.apache.logging.log4j.core.appender.rewrite.RewritePolicy
+import org.apache.logging.log4j.core.config.plugins.Plugin
+import org.apache.logging.log4j.core.config.plugins.PluginFactory
+import org.apache.logging.log4j.core.impl.Log4jLogEvent
+
+@Plugin(name = "ErrorCodeRewritePolicy", category = Core.CATEGORY_NAME, elementType = "rewritePolicy", printObject = false)
+class ErrorCodeRewritePolicy : RewritePolicy {
+ override fun rewrite(source: LogEvent?): LogEvent? {
+ val newMessage = source?.message?.withErrorCodeFor(source.thrown, source.level)
+ return if (newMessage == source?.message) {
+ source
+ } else {
+ Log4jLogEvent.Builder(source).setMessage(newMessage).build()
+ }
+ }
+
+ companion object {
+ @JvmStatic
+ @PluginFactory
+ fun createPolicy(): ErrorCodeRewritePolicy {
+ return ErrorCodeRewritePolicy()
+ }
+ }
+}
\ No newline at end of file
diff --git a/tools/cliutils/src/main/resources/log4j2.component.properties b/tools/cliutils/src/main/resources/log4j2.component.properties
deleted file mode 100644
index dab7dd2d32..0000000000
--- a/tools/cliutils/src/main/resources/log4j2.component.properties
+++ /dev/null
@@ -1 +0,0 @@
-log4j.configurationFactory=net.corda.cliutils.CordaLog4j2ConfigFactory
\ No newline at end of file