You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by David KOCH <dk...@ezakus.com> on 2015/07/06 13:14:49 UTC

Get properties from configuration programatically.

Hello,

Is there a way to get the properties from a log4j2 configuration file
programatically?

Like:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG" monitorInterval="10">

  <Properties>
    <Property name="kafkaHost">localhost:9092</Property>
  </Properties>

  ...
</Configuration>

I tried:

LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
ctx.getConfiguration().getProperties();

However, this only returns global properties like hostName and not the
custom ones I added to the configuration.

Thank you,

/David