I wrote a stupid rule to see whether logging can work in rules with the latest openhab core on the master branch. And I use the development environment to test it, which is the app.bndrun.
rule “TestLog”
when
Time cron “5 * * * * ?”
then
logWarn(“TestLog”, “Test Start!”)
logWarn(“TestLog”, “Test End!”)
end
Also I add the following logging entry in the logback.xml.
However, I get the error like the following and I cannot see the test output like “Test Start!” in the console.
22:24:05.714 [ool-12-thread-1] ERROR o.o.c.m.s.r.i.engine.DSLScriptEngine:103 - Script references context ‘testLog-1’, but no context provider is registered!
Does anyone have any advice? Why can’t I use logWarn and get the output? By the way, I am using openhab core on the master branch.
This no longer exists… not only have all references to ESH in package names been changed over to the org.openhab namespace, but the old rule engine has also been removed.
You’ll want to start up at org.openhab.core.automation.
No, the path is org.openhab.demo.app/runtime/userdata/logback.xml. By the way, I inject RuleMananger, and use it to run the rule directly. However it shows me the following information.
17:58:16.093 [OH-stam-2] ERROR o.o.c.m.s.r.i.engine.DSLScriptEngine:103 - Script references context ''testLog-1", but no context provider is registered!
where testLog.rules is the name of the rule file. Any idea?
By the way, RuleMananger is a service in the org.openhab.core.automation, and I injected it. I don’t get it when you say “use scripted automation”. Could you give me some hints?
Sorry, typo… org.openhab.core.automation. You’re logback.xml only had it set to WARN. Make sure you have the latest and make sure you have the new rule engine enabled. I may have been lumped in with a bunch of other changes, but I don;t recall a PR that specifically enabled it by default.
It is strange, because in my rule, I use logWarn. Actually setting to DEBUG level gives me a lot of log, and I didn’t find any log which is related to my rule…
I just saw the trigger you’re using. ‘System started’ had to be remade for the new rule engine and may not work yet. Try a cron trigger that fires every 5s.
That’s a huge progress. At least now there is a warnning message.
22:24:05.714 [ool-12-thread-1] ERROR o.o.c.m.s.r.i.engine.DSLScriptEngine:103 - Script references context ‘testLog-1’, but no context provider is registered!