I am try to figure out if it's possible to use log4j appender to output messages (log lines) in my google container engine application so that they can be properly handled by the google cloud logging agent that runs of the box.
Is there a place where the log format is documented or something similar.
All you need is to write your logs to stdout in container. All containers in kubernetes are listened by another container fluentd for STDOUT. Simply put consolappender to the config and logs will appear in
<configuration>
<!--Daily rolling file appender-->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>target/surefire-reports/blah-logback.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>blah-logback.log.%d{yyyy-MM-dd}</FileNamePattern>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%-10.10thread] %logger{36} - %msg%n%rEx</Pattern>
<immediateFlush>true</immediateFlush>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="FILE"/>
<appender-ref ref="STDOUT"/>
</root>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With