I'm having a strange issue where log4j is correctly displaying all my log messages the console, but is only sending log messages to my graylog server that I am not writing (e.g. a library I'm using which writes to log.info
will show up in graylog, but not any of the messages I write with log.info
). What am I missing
Here's my logback-spring.xml
<configuration>
<contextName>test</contextName>
<jmxConfigurator/>
<springProfile name="dev, test">
<appender name="gelf" class="biz.paluch.logging.gelf.logback.GelfLogbackAppender">
<host>udp:localhost</host>
<port>5555</port>
<version>1.1</version>
<extractStackTrace>true</extractStackTrace>
<filterStackTrace>true</filterStackTrace>
<mdcProfiling>true</mdcProfiling>
<timestampPattern>yyyy-MM-dd HH:mm:ss,SSS</timestampPattern>
<maximumMessageSize>8192</maximumMessageSize>
<includeFullMdc>true</includeFullMdc>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
</appender>
</springProfile>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<logger name="com.test" level="info" additivity="false">
<appender-ref ref="stdout" />
</logger>
<root level="INFO">
<appender-ref ref="gelf" />
<appender-ref ref="stdout" />
</root>
</configuration>
I'm instantiating my log by doing:
private static final Logger logger = LogManager.getLogger(MyClass.class);
And writing to my log:
logger.info("WHY CAN'T I SEE THIS IN MY GRAYLOG SERVER");
Edit:
Your are specifying that the loggers of the package com.test
should only write to the stdout
appender.
<logger name="com.test" level="info" additivity="false">
<appender-ref ref="stdout" />
</logger>
You should change it to:
<logger name="com.test" level="info" />
Make sure that you are running your app with the matching profile for your gelf appender.