context
I'm using logback in spring boot, i have created a custom appender. But when initialising custom appender (appender's constructor) sometimes getting error and the actual error is not logger in to logger or any other place, so it's become hard to solve.
error message
ERROR in ch.qos.logback.core.joran.action.AppenderAction - Could not create an Appender of type [com.river.myapp.api.azure.monitor.AzureMonitorAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type com.river.myapp.api.azure.monitor.AzureMonitorAppender
ERROR in ch.qos.logback.core.joran.spi.Interpreter@10:104 - ActionException in Action for tag [appender] ch.qos.logback.core.joran.spi.ActionException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type com.river.myapp.api.azure.monitor.AzureMonitorAppender
ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [AZUREMONITOR]. Did you define it below instead of above in the configuration file?
ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:169)
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:118)
at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:306)
at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:281)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:216)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:80)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
actual error should include
In custom logger's constructor below error is throwing but if you see above error trace, nothing mentioned about below actual error
throw new Exception("Unable to resolve service provider")
logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<appender name="AZUREMONITOR" class="com.river.myapp.api.azure.monitor.AzureMonitorAppender"/>
<root level="INFO">
<appender-ref ref="AZUREMONITOR"/>
</root>
</configuration>
what i tried
I tried use println(), org.slf4j.LoggerFactory but no help, also check the system logs.
what i looking for
The way i can log the actual error occurs while initialising custom appender (in short error in appender's contractor)