After tried to upgrade cxf & log4j2 versions in our spring java application; cxf from 2 -> 3.1 & log4j 1.x -> 2.x; the logging is broken. Rolling file appender & smtp appenders doesn't log the exceptions anymore. while running the application in maven-jetty plugin, the exception is getting printed to console. All other loggers are getting printed well but exceptions are not. couldn't figure out what is wrong.
applicationcontext.xml
<bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
<bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
<jaxrs:server id="serviceResource" address="/rest">
<jaxrs:serviceBeans>
<ref bean="endpoint1"/>
<ref bean="endpoint2"/>
</jaxrs:serviceBeans>
<!-- this is removed after migrating to new cxf 3 infavor of exception mappers
<jaxrs:outFaultInterceptors>
<ref bean="cxfRestFaultInterceptor"/>
</jaxrs:outFaultInterceptors>
-->
<jaxrs:inInterceptors>
<ref bean="logInbound"/>
</jaxrs:inInterceptors>
<jaxrs:outInterceptors>
<ref bean="logOutbound"/>
</jaxrs:outInterceptors>
<jaxrs:providers>
<bean id="businessExceptionMapper"
class="com.commons.interceptors.BusinessExceptionMapper">
<property name="exceptionMessageSource" ref="exceptionMessageSource"/>
<property name="exceptionCodeSource" ref="exceptionCodeSource"/>
</bean>
<bean id="globalExceptionMapper"
class="com.common.interceptors.GlobalExceptionMapper">
<property name="messageSource" ref="messageSource"/>
</bean>
<bean id="applicationExceptionMapper"
class="com.common.interceptors.ApplicationExceptionMapper">
<property name="messageSource" ref="messageSource"/>
</bean>
<ref bean='jacksonProvider'/>
</jaxrs:providers>
</jaxrs:server>
log4j2.xml
<Configuration>
<Appenders>
<RollingFile
name="fileout"
fileName="../logs/web.log"
filePattern="../logs/web.%i.log"
ignoreExceptions="false"
append="true">
<PatternLayout>
<Pattern>[%d{DATE}] - %X{hostName} - [%-5p][%c{1},%t] - %m%n</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="2MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
<SMTP
name="mail"
from="from_email"
to="to_email"
subject="APIWebError"
smtpHost="smtp_host">
<HtmlLayout/>
</SMTP>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="fileout"/>
<AppenderRef ref="mail"/>
</Root>
</Loggers>
</Configuration>
Note: outFaultInterceptors was used previously but removed it and used the exceptionmapper in the providers section; as recommended by the org team.
This has been resolved after reordering the exception mappers and logging the error explicitly with log.error. There's nothing wrong with log4j configuration.