First, for the logging level of bindings you can set the level by navigating to Settings → Bindings → Binding Name and click the little gear icon in the upper right or through the REST API or through the Karaf Console, or by editing log4j2.xml.
Unfortunately the REST API doesn’t support changing any other logger’s logging level so you’ll have to change those using the Karaf console, or by editing log4j2.xml and adding a new Logger to the bottom and setting the level there.
JS Scripting also supports setting the logging level in the rule itself.
oh, that’s cool, didn’t know that - I always went right into the Karaf Console.
But - what I really meant was just to add some Rules-Logging:
console.info("here some info values: " + INFOVARIABLE);
console.debug("here some debug values: " + DEBUGVARIABLE);
What I want is to leave the rule “as is”, but print the console.debug values only to the logs, if I want to really debug my rules, not 24/7.
But I think I found it here:
log:set debug org.openhab.core.model.script should do it then.
But: Is there a JS Scripting equivalent for logging a “subpackage” in DLS with logError("heating", "This is a log entry of type Error!"), meaning I could set only the “heating” logs to e.g. DEBUG?
2023-02-15 16:16:49.946 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'EMS_HauptProgramm' failed: org.graalvm.polyglot.PolyglotException: TypeError: (intermediate value).myRulesName is not a function
That gives the logger it’s name. In this case, on the Karaf Console, or in the log4j2.xml file that’s the name I’d use for the “name” of the logger.
But that doesn’t change how console works. You still use console.info("blah blah blah");, console.debug("blah blah blah"); and so on.
and with that set, I get iwith the following console-commands:
console.info("a INFO logentry");
console.debug("a DEGUB logentry");
console.info("a INFO logentry again");
2023-02-15 17:23:52.070 [INFO ] [tomation.script.ui.TestRule] - a INFO logentry
2023-02-15 17:23:52.071 [DEBUG] [tomation.script.ui.TestRule] - a DEBUG logentry
2023-02-15 17:23:52.073 [INFO ] [tomation.script.ui.TestRule] - a INFO logentry again
and of course the DEBUG logentry is gone, if I set log:set INFO org.openhab.automation.script in e.g. the console