CORDA-2183: Show root cause of error in console to aid with debugging (#4178)

* Show root cause of error in console

* Add more explicit logical separator between message and root error

* Add default if e.cause is null
This commit is contained in:
Anthony Keenan
2018-11-06 22:15:22 +00:00
committed by GitHub
parent ac64b6c37c
commit 6fd724338a
2 changed files with 7 additions and 3 deletions

View File

@ -12,7 +12,7 @@
<Appenders> <Appenders>
<Console name="Console-Appender" target="SYSTEM_OUT"> <Console name="Console-Appender" target="SYSTEM_OUT">
<PatternLayout> <PatternLayout>
<ScriptPatternSelector defaultPattern="%highlight{[%level{length=5}] %date{HH:mm:ssZ} [%t] %c{2}.%method - %msg%n%throwable{short.message}}{INFO=white,WARN=red,FATAL=bright red}"> <ScriptPatternSelector defaultPattern="%highlight{[%level{length=5}] %date{HH:mm:ssZ} [%t] %c{2}.%method - %msg%n%throwable{short.message}%n}{INFO=white,WARN=red,FATAL=bright red}">
<Script name="MDCSelector" language="javascript"><![CDATA[ <Script name="MDCSelector" language="javascript"><![CDATA[
result = null; result = null;
if (!logEvent.getContextData().size() == 0) { if (!logEvent.getContextData().size() == 0) {
@ -23,7 +23,7 @@
result; result;
]]> ]]>
</Script> </Script>
<PatternMatch key="WithMDC" pattern="%highlight{[%level{length=5}] %date{HH:mm:ssZ} [%t] %c{2}.%method - %msg %X%n%throwable{short.message}}{INFO=white,WARN=red,FATAL=bright red}"/> <PatternMatch key="WithMDC" pattern="%highlight{[%level{length=5}] %date{HH:mm:ssZ} [%t] %c{2}.%method - %msg %X%n%throwable{short.message}%n}{INFO=white,WARN=red,FATAL=bright red}"/>
</ScriptPatternSelector> </ScriptPatternSelector>
</PatternLayout> </PatternLayout>
</Console> </Console>

View File

@ -554,7 +554,11 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
log.error("${it.name}, as a Corda service, must have a constructor with a single parameter of type " + log.error("${it.name}, as a Corda service, must have a constructor with a single parameter of type " +
ServiceHub::class.java.name) ServiceHub::class.java.name)
} catch (e: ServiceInstantiationException) { } catch (e: ServiceInstantiationException) {
log.error("Corda service ${it.name} failed to instantiate", e.cause) if (e.cause != null) {
log.error("Corda service ${it.name} failed to instantiate. Reason was: ${e.cause?.rootMessage}", e.cause)
} else {
log.error("Corda service ${it.name} failed to instantiate", e)
}
} catch (e: Exception) { } catch (e: Exception) {
log.error("Unable to install Corda service ${it.name}", e) log.error("Unable to install Corda service ${it.name}", e)
} }