Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating cloud watch appender with version 1.8.2-JAVA9MODULE_SLF4J17 and 1.8.1-JAVA9MODULE_SLF4J17 #60

Closed
rackdon opened this issue Oct 16, 2020 · 4 comments

Comments

@rackdon
Copy link

rackdon commented Oct 16, 2020

I obtain an error when trying to initialize the cloud watch appender with version 1.8.2-JAVA9MODULE_SLF4J17 or 1.8.1-JAVA9MODULE_SLF4J17.
It works fine with 1.8.0-JAVA9MODULE_SLF4J17 version.
The error obtained is

Exception in thread "main" java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.action.AppenderAction - Could not create an Appender of type [ch.qos.logback.more.appenders.CloudWatchLogbackAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.more.appenders.CloudWatchLogbackAppender
ERROR in ch.qos.logback.core.joran.spi.Interpreter@16:97 - ActionException in Action for tag [appender] ch.qos.logback.core.joran.spi.ActionException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.more.appenders.CloudWatchLogbackAppender
	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)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
	at roc.backend.backoffice.BackofficeApplicationKt.main(BackofficeApplication.kt:16)

My Logback file is

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="1 seconds" debug="false">
    <variable name="LOG_LEVEL" value="${LOG_LEVEL:-WARN}" />
    <variable name="AWS_REGION" value="${AWS_REGION:-eu-west-1}" />
    <include resource="org/springframework/boot/logging/logback/defaults.xml" />
    <include resource="org/springframework/boot/logging/logback/console-appender.xml" />

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{"yyyy-MM-dd'T'HH:mm:ss,SSS", UTC} [%thread] %-5level %logger{36} - %replace(%msg){'[\r\n]',''} %replace(%ex){'[\r\n]+', '\\n'}%nopex %n</pattern>
        </encoder>
    </appender>

    <appender name="Sentry" class="io.sentry.logback.SentryAppender"/>

    <appender name="CLOUDWATCH" class="ch.qos.logback.more.appenders.CloudWatchLogbackAppender">
        <awsConfig>
            <!--        Uncomment when need to verify that cloudwatch works-->
            <profile>admin-dev</profile>
            <region>${AWS_REGION}</region>

        </awsConfig>
        <logGroupName>BackofficeAuditory</logGroupName>
        <logStreamName>auditory</logStreamName>
        <logStreamRolling class="ch.qos.logback.more.appenders.CloudWatchLogbackAppender$CountBasedStreamName">
            <limit>100000</limit>
        </logStreamRolling>
        <createLogDestination>true</createLogDestination>
        <emitInterval>100</emitInterval>
    </appender>

    <springProfile name="local">

<!--        Uncomment when need to verify that cloudwatch works-->
<!--        <logger name="roc.backend.backoffice.service.AuditService" level="INFO">-->
<!--            <appender-ref ref="CLOUDWATCH" />-->
<!--        </logger>-->
        <root level="INFO">
            <appender-ref ref="CONSOLE" />
        </root>
    </springProfile>

    <springProfile name="!local">
        <logger name="roc.backend.backoffice.service.AuditService" level="INFO" additivity="false">
            <appender-ref ref="CLOUDWATCH"/>
        </logger>
        <root level="${LOG_LEVEL}">
            <appender-ref ref="CONSOLE" />
            <appender-ref ref="Sentry" />
        </root>
    </springProfile>

</configuration>
@sndyuk
Copy link
Owner

sndyuk commented Oct 24, 2020

@rackdon Thank you for the report! It's been fixed on version 1.8.3.

@rackdon
Copy link
Author

rackdon commented Oct 26, 2020

The problem remains in 1.8.3

Exception in thread "main" java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.action.AppenderAction - Could not create an Appender of type [ch.qos.logback.more.appenders.CloudWatchLogbackAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.more.appenders.CloudWatchLogbackAppender
ERROR in ch.qos.logback.core.joran.spi.Interpreter@16:97 - ActionException in Action for tag [appender] ch.qos.logback.core.joran.spi.ActionException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.more.appenders.CloudWatchLogbackAppender

@sndyuk sndyuk removed the 4 - Done label Oct 28, 2020
@sndyuk
Copy link
Owner

sndyuk commented Oct 28, 2020

@rackdon Reproduced the error when I remove the line from module-info.java in an app. Do you have the line?

requires transitive org.slf4j;

@rackdon
Copy link
Author

rackdon commented Oct 28, 2020

no sorry, why should I have that line?. My project is also in kotlin

@sndyuk sndyuk closed this as completed Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants