I currently use spring cloud netflix with log4j2. The log4j2 configuration comes from the xml in the classpath. When I run the app, I see that the feign & ribbon logs are not being redirected to the logger specified in the configuration. I have configured log for com.netflix.ribbon & feign packages to be logged at debug level.
However, log configured for spring is properly redirecting to the specified appender, ribbon & feign are not.
I am using gradle with spring-boot-starter-logging ignored & added spring-boot-starter-log4j2 in as part of my build.
I see that feign has a way by which we can configure slf4j, but since we use annotation driven feign support, I cant configure the feign to use slf4j for logging.
Any help is appreciated.
My log4j2.xml looks some what like
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Properties>
<Property name="log-path">logs</Property>
<Property name="log-fileName">test</Property>
</Properties>
<Appenders>
<Console name="console-log" target="SYSTEM_OUT">
<PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" />
</Console>
<RollingFile name="trace-log" fileName="${log-path}/${log-fileName}-trace.log" filePattern="${log-path}/${log-fileName}_trace-%d{yyyy-MM-dd}.log">
<PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" />
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
</Policies>
</RollingFile>
<RollingFile name="error-log" fileName="${log-path}/${log-fileName}-error.log" filePattern="${log-path}/${log-fileName}_error-%d{yyyy-MM-dd}.log">
<PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" />
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<logger name="org.springframework" level="trace" additivity="false">
<AppenderRef ref="trace-log" />
</logger>
<logger name="feign" level="trace" additivity="false">
<AppenderRef ref="trace-log" />
</logger>
<logger name="com.netflix.ribbon" level="trace" additivity="false">
<AppenderRef ref="trace-log" />
</logger>
<Root level="info">
<AppenderRef ref="console-log"></AppenderRef>
<AppenderRef ref="error-log" level="ERROR"/>
</Root>
</Loggers>
</Configuration>
PS: The reason for debugging feign/ribbon is to understand a weird feign behavior between two different machines in our micro services setup
Looking at Spring Cloud's
FeignClientFactoryBean
shows that you can optionally autowire a bean of typefeign.Logger.Level
. Try registering such a bean in your@Configuration
using