Capture all logs and errors in the Pantheon log output (#1437)

* Add slf4j to log4j bindings as a runtime dependency so any libraries that log to slf4j have their logs output to Pantheon's logs properly.

* Set a default exception handler to ensure uncaught exceptions wind up in the Pantheon logs.

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Adrian Sutton 6 years ago committed by GitHub
parent 5dffb2e721
commit d87b6c4416
  1. 1
      pantheon/build.gradle
  2. 8
      pantheon/src/main/java/tech/pegasys/pantheon/Pantheon.java

@ -54,6 +54,7 @@ dependencies {
implementation 'org.springframework.security:spring-security-crypto'
runtime 'org.apache.logging.log4j:log4j-core'
runtime 'org.apache.logging.log4j:log4j-slf4j-impl'
testImplementation project(':testutil')
testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts')

@ -21,6 +21,7 @@ import tech.pegasys.pantheon.ethereum.eth.sync.SynchronizerConfiguration;
import tech.pegasys.pantheon.services.kvstore.RocksDbConfiguration;
import tech.pegasys.pantheon.util.BlockImporter;
import org.apache.logging.log4j.Logger;
import picocli.CommandLine.RunLast;
public final class Pantheon {
@ -28,10 +29,13 @@ public final class Pantheon {
private static final int ERROR_EXIT_CODE = 1;
public static void main(final String... args) {
final Logger logger = getLogger();
Thread.setDefaultUncaughtExceptionHandler(
(thread, error) ->
logger.error("Uncaught exception in thread \"" + thread.getName() + "\"", error));
final PantheonCommand pantheonCommand =
new PantheonCommand(
getLogger(),
logger,
new BlockImporter(),
new RunnerBuilder(),
new PantheonController.Builder(),

Loading…
Cancel
Save