CORDA-2506: Better handling of invalid log path (#4895)

Test if we have access to the logging path (baseDirectory/logs) before attempting to write to them. This allows us to shut down gracefully with an easily understandable error message.
Without doing this, the log4j2 will attempt to access the logPath when it first uses the logger in the call() function.
This commit is contained in:
Jonathan Locke
2019-03-15 09:54:53 +00:00
committed by Shams Asari
parent 03967742e4
commit 82c45c6f83
5 changed files with 36 additions and 11 deletions

View File

@ -56,10 +56,11 @@ class StandaloneShell : CordaCliWrapper("corda-shell", "The Corda standalone she
private fun getManifestEntry(key: String) = if (Manifests.exists(key)) Manifests.read(key) else "Unknown"
override fun initLogging() {
override fun initLogging() : Boolean {
super.initLogging()
SLF4JBridgeHandler.removeHandlersForRootLogger() // The default j.u.l config adds a ConsoleHandler.
SLF4JBridgeHandler.install()
return true
}
override fun runProgram(): Int {