Trouble with Logger.getLogger call in TypeDescriptor for usage in log4j2 instantiation

Issue #461 open
cen1 cen1 created an issue

We have a peculiar problem introduced by snakeyaml 1.19 which adds this line to TypeDescriptor:

final private static Logger log = Logger
        .getLogger(TypeDescription.class.getPackage().getName());

We use snakeyaml to parse a yaml config file. The parsed config is used to instantiate log4j2, eventually leading to the call: System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager"); (just a sample, in reality this is determined dynamically if log4j2 extension is detected).

Unfortunately this property must be set before any call to LogManager or Logger: “…by using System.setProperty() before any calls are made to LogManager or Logger.“ ..so essentially that line breaks our log4j2 instantiation.

The trickiest part is that we can’t move our log4j2 init code before snakeyaml parser because we rely on the config to be parsed first so it’s a catch 22. This essentially means snakeyaml can’t be used to configure log4j2.

Any idea how we could work around this issue?

Comments (0)

  1. Log in to comment