Corda-1155 - Jolokia logging via slf4j (#2753)

* Jolokia logging through slf4j

* review remarks
This commit is contained in:
Andrzej Grzesik 2018-03-07 14:12:15 +01:00 committed by ags
parent 4e5df2f4fb
commit 803ce15b32
No known key found for this signature in database
GPG Key ID: 79EBE5A3D6E758E4
5 changed files with 90 additions and 1 deletions

View File

@ -60,5 +60,9 @@
<Logger name="org.apache.activemq.artemis.core.server" level="error" additivity="false">
<AppenderRef ref="RollingFile-Appender"/>
</Logger>
<Logger name="org.jolokia" additivity="true" level="warn">
<AppenderRef ref="Console-Appender-Println"/>
<AppenderRef ref="RollingFile-Appender" />
</Logger>
</Loggers>
</Configuration>

View File

@ -175,7 +175,8 @@ dependencies {
testCompile "org.glassfish.jersey.containers:jersey-container-servlet-core:${jersey_version}"
testCompile "org.glassfish.jersey.containers:jersey-container-jetty-http:${jersey_version}"
runtime "org.jolokia:jolokia-jvm:${jolokia_version}:agent"
// Jolokia JVM monitoring agent
compile "org.jolokia:jolokia-jvm:${jolokia_version}:agent"
}
task integrationTest(type: Test) {

View File

@ -0,0 +1,40 @@
package net.corda.node
import org.jolokia.util.LogHandler
import org.slf4j.Logger
import org.slf4j.LoggerFactory
/**
* This also exists in webserver, because depends on jolokia
**/
class JolokiaSlf4Adapter : LogHandler {
companion object {
val log: Logger = LoggerFactory.getLogger("org.jolokia")
}
override fun error(message: String?, t: Throwable?) {
if (message != null) {
if (t != null) {
log.error(message, t)
} else {
log.error(message)
}
} else if (t != null) {
log.error("Exception without a comment", t)
}
}
override fun debug(message: String?) {
if (message != null) {
log.debug(message)
}
}
override fun info(message: String?) {
if (message != null) {
log.info(message)
}
}
}

View File

@ -25,5 +25,9 @@
<Logger name="org.hibernate.SQL" level="info" additivity="false">
<AppenderRef ref="Console-Appender"/>
</Logger>
<Logger name="org.jolokia" additivity="true" level="warn">
<AppenderRef ref="Console-Appender-Println"/>
<AppenderRef ref="RollingFile-Appender" />
</Logger>
</Loggers>
</Configuration>

View File

@ -0,0 +1,40 @@
package net.corda.webserver
import org.jolokia.util.LogHandler
import org.slf4j.Logger
import org.slf4j.LoggerFactory
/**
* This also exists in node, because depends on jolokia
**/
class JolokiaSlf4Adapter : LogHandler {
companion object {
val log: Logger = LoggerFactory.getLogger("org.jolokia")
}
override fun error(message: String?, t: Throwable?) {
if (message != null) {
if (t != null) {
log.error(message, t)
} else {
log.error(message)
}
} else if (t != null) {
log.error("Exception without a comment", t)
}
}
override fun debug(message: String?) {
if (message != null) {
log.debug(message)
}
}
override fun info(message: String?) {
if (message != null) {
log.info(message)
}
}
}