Search This Blog

log4j2: conditional appender using routes

<?xml version="1.0"?>
<Configuration status="INFO">
  <Appenders>
    <Console name="SYS_OUT" target="SYSTEM_OUT" />
    <Console name="SYS_ERR" target="SYSTEM_ERR" />

    <Routing name="Router">
      <Routes pattern="$${env:STREAM_TO:-OUT}">
        <Route ref="SYS_OUT" key="OUT" />
        <Route ref="SYS_ERR" key="ERR" />
      </Routes>
    </Routing>
  </Appenders>

  <Loggers>
    <Root level="INFO">
      <AppenderRef ref="Router" />
    </Root>
  </Loggers>
</Configuration>

see also

No comments:

Post a Comment