You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/09/04 23:01:00 UTC
[jira] [Commented] (GROOVY-10748) logback-classic 1.3.0 and 1.4.0 breaks on Groovy
[ https://issues.apache.org/jira/browse/GROOVY-10748?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17600118#comment-17600118 ]
Paul King commented on GROOVY-10748:
------------------------------------
You need to delete the slf4j-api-1.7.32.jar in your Groovy install's lib directory since you can't mix slf4j 1.x and 2.x. That jar is in the standard distribution to support TestNG, so if you delete it, you will need to add some @Grab statements to any TestNG tests that you want to run in the Groovy console.
Alternatively, you can use a Maven/Gradle build for your project and ensure that old slf4j dependencies aren't included.
We should probably look at bumping the TestNG slf4j dependency to 2.0 since that seems to cause less problems even with 1.x slf dependencies explicitly added.
> logback-classic 1.3.0 and 1.4.0 breaks on Groovy
> ------------------------------------------------
>
> Key: GROOVY-10748
> URL: https://issues.apache.org/jira/browse/GROOVY-10748
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 4.0.4
> Reporter: Ramesh Venkitaswaran
> Priority: Minor
>
> Logging is not working when using logback version 1.3.0 or 1.4.0. The slf4j version is 2.0.0. This error is emitted.
> {noformat}
> SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
> SLF4J: Defaulting to no-operation (NOP) logger implementation
> SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
> {noformat}
> I searched the logback-user mailing lists and found a thread on Sep 1 and it had a link to this github issue for Spring ([https://github.com/spring-projects/spring-boot/issues/12649]) which also has a similar issue. The link to the thread is here ([http://mailman.qos.ch/pipermail/logback-user/2022-September/005231.html])
> Test logback.xml
> {code:xml}
> <configuration>
> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
> <encoder>
> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
> </encoder>
> </appender>
> <root level="debug">
> <appender-ref ref="STDOUT"/>
> </root>
> </configuration>
> {code}
> Sample groovy test code. Changing version 1.3.0 to 1.2.11 will work. Also tested with 1.4.0 and it does not work.
> {code:groovy}
> @Grab('org.slf4j:slf4j-api:2.0.0')
> @Grab('ch.qos.logback:logback-classic:1.3.0')
> @GrabConfig(systemClassLoader=true)
> import org.slf4j.*
> import groovy.util.logging.*
> @Slf4j(category="hello")
> class Hello {
> def useLogger() {
> log.info 'logging works'
> log.debug 'debugging!!!'
> }
> }
> static main(args) {
> def h = new Hello()
> h.useLogger()
> }
> {code}
> To run:
> {noformat}
> groovy -Dlogback.configurationFile=/path/to/logback.xml /path/to/script.groovy
> {noformat}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)