This project helps logging all log messages to Google Cloud Logging via an log4j2 Appender.
Add the following maven dependency to your pom.xml
:
<dependency>
<groupId>eu.zirrus.gcloud.logging</groupId>
<artifactId>log4j</artifactId>
<version>0.1.0</version>
</dependency>
or with gradle:
compile 'eu.zirrus.gcloud.logging:log4j:0.1.0'
This is a sample config which adds a CloudLogging Appender called CloudLogginTest. The Appender is wrapped in an AsyncAppender to run in non-blocking mode.
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<CloudLogging name="CloudLoggingTest" projectId="allcyte-akira">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</CloudLogging>
<Console name="Console">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
<Async name="CloudLoggingAsync">
<AppenderRef ref="CloudLoggingTest"/>
</Async>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console" level="error"/>
<AppenderRef ref="CloudLoggingAsync" />
</Root>
</Loggers>
</Configuration>