Hello, OpenHAB 4.2.1 is written in Java and has a Groovy 4.0.11 plugin to programme logic. It allows writing code outside of classes, which is executed immediately. When I place a file openhab/jsr223/test.groovy:
import org.slf4j.LoggerFactory logger = LoggerFactory.getLogger("l") class A { public A() { logger.info("L") } } A a = new A() the system logs 2024-08-21 12:15:21.061 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script ‘/etc/openhab/automation/jsr223/test.groovy’: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: logger for class: A How can I make logger visible within the methods of class A, without passing it as parameter to the constructor? Also asked at https://community.openhab.org/t/groovy-how-to-access-global-variable-from-a-class/ . Kind regards Дилян