[
https://issues.apache.org/jira/browse/GROOVY-11049?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17721608#comment-17721608
]
Devaprasadh Xavier commented on GROOVY-11049:
---------------------------------------------
I can confirm that adding '@GrabConfig(systemClassLoader=true)' to the script
does make the logging work. Thanks!
> Logging with Slf4j doesn't work in scripts
> ------------------------------------------
>
> Key: GROOVY-11049
> URL: https://issues.apache.org/jira/browse/GROOVY-11049
> Project: Groovy
> Issue Type: Bug
> Components: GroovyScriptEngine
> Affects Versions: 3.0.10, 3.0.17, 4.0.12
> Environment: OS: Mac OS X, Ubuntu 22.04
> Groovy versions affected: 3.0.10+, 4.x
> Groovy versions working as expected: 2.5.x(2.5.22), 3.x till 3.0.9
> JDK versions: Tested in JDK11 and JDK17
> Reporter: Devaprasadh Xavier
> Priority: Major
>
> *Test script:*
> {code:java}
> @Grab(group = 'ch.qos.logback', module = 'logback-classic', version = '1.4.7')
> import org.slf4j.LoggerFactory
> LoggerFactory.getLogger('test').info('Hello, World!')
> {code}
> *Expected output: (works in 2.5.22 and 3.x till 3.0.9)*
> {code:java}
> 07:21:03.685 [main] INFO test -- Hello, World! {code}
> *Actual output in 3.x versions above 3.0.9:*
> {code:java}
> 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.
> {code}
> *Actual output in 4.x versions:* **
> {code:java}
> SLF4J: No SLF4J providers were found.
> SLF4J: Defaulting to no-operation (NOP) logger implementation
> SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)