custom logger for log4j2 over slf4j.
This is a custom logger for log4j2 that obeys the rules laid down by the Connect platform for distributed logging.
To use it in your log4j2 configuration, add it in packages you should be scanning, ideally identify it specifically by its classname so it does not scan at all.
The package is nz.net.osnz.common.logging.CloudJsonLayout
and it is designed to log to stdout
as all distributed loggers are, including Google Cloud Stackdriver.
<Configuration monitorInterval="30" verbose="true">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<CloudJsonLayout />
</Console>
</Appenders>
<Loggers>
<AsyncLogger name="io.osnz" level="debug" />
<!-- Reduce noise -->
<AsyncLogger name="com.amazonaws" level="warn"/>
<AsyncLogger name="org.springframework" level="info"/>
<AsyncLogger name="org.springframework.beans.factory" level="warn"/>
<AsyncLogger name="org.apache" level="warn"/>
<AsyncLogger name="org.hibernate" level="warn"/>
<AsyncLogger name="org.glassfish" level="warn"/>
<AsyncLogger name="org.jboss" level="warn"/>
<!-- this controls whether each HTTP request is logged (very verbose) -->
<AsyncLogger name="jersey-logging" level="trace"/>
<AsyncRoot level="info">
<AppenderRef ref="Console"/>
</AsyncRoot>
</Loggers>
</Configuration>