Debug Logging in JS Rule

Hi,

I’m using JS automation for creating UI based rules in OH 3.4. I tried to use the debug function as described here:

but I am not able do enable DEBUG logging for my rule. The name of my rule is chargecontrolelectricvehicle and this is my code:

var logger = log('org.openhab.rule.' + ctx.ruleUID);
logger.info("Script Ladesteuerung is starting INFO");
logger.debug("Script Ladesteuerung is starting DEBUG");

In karaf konsole I tried to activate debug logging with log:set DEBUG org.openhab.rule.chargecontrolelectricvehicle, but only the logger.info message is printed in openhab.log. Is anyone able to tell me what I am doing wrong?

Cheers,
kuczerek.

Why don‘t you use the console.debug logger? See JavaScript Scripting - Automation | openHAB.

But anyway, I‘m wondering why the debug message is not displayed in the log.

Hi,

because I don’t know how to activate a rule specific debugging in karaf console, if I use
console.debug logger.

I want to be able to activate the debugging mode only for one rule to prevent the logfile of being flooded with lots of messages.

The default logger name consists of the prefix org.openhab.automation.script and the script’s individual part .file.filename or .ui.ruleUID.

For a UI rule named abc the logger name would be org.openhab.automation.script.ui.abc.

Using

log:set DEBUG org.openhab.automation.script.ui.abc

should enable debug logging for this rule.

Brilliant, Thanks!