and then loaded the file “logtest.rules” which contains a single rule:
//Turn on the wemo mini switch when openhab2 launches
rule "first rule"
when
System started
then
val input = executeCommandLine("C:\\head@@-n@@1@@C:\\openhabinput.txt", 5000)//no complaints
logDebug("logtest", "this is a log entry of type debug")
Switch1_state.sendCommand(ON)
end
The rule is triggering (as evidenced by the switch turning on) but I don’t see any logging information either in the console nor in the log files.
Are the above console commands correct?
I used the name of the .rules file as the 1st argument to logDebug. Is this correct?
Thanks very much for the reply. I’m making progress.
It turns out that if I use logWarn as in your example I DO see logging. However, if I use logDebug I DON’T see logging. I am now experimenting with what other logging levels do or don’t act as I expect. (I am using openhab 2.1)
In the meantime,
do you set your log level in the console or do you have a configuration file? (Maybe that makes a difference?)
would it be possible for you to change your log level to DEBUG/logDebug and let me know what happens?
some place in the documentation I remember seeing the syntax for using the Java format style of substituting variable values into the output string but I can’t find it anymore. Have you seen that or do you have an example in any of your rules?
If that’s not a typo, I think it’s wrong. Should be this instead:
log:set DEBUG org.eclipse.smarthome.model.script.logtest.rules
or just
log:set DEBUG org.eclipse.smarthome.model.script
My full reply follow, which you may or may not need…
Depends. For quick debugging, I usually set the log level in the console. If I’m going to be doing extensive work I occasionally use the configuration file.
Bingo. I guess I will have to learn to read more carefully. Everything is good now.
Regarding my 3rd question above:
in Java there is a format method which formats arguments into a string.
The syntax is, for example,
String formattedString = String.format("the temperature is %.2f",temp)
where temp is a Double or double. The value of temp will be reported to 2 places. I had seen An example of DEBUG output that used the Java format syntax to format the output of logDebug. However, despite searching all over the place I couldn’t find this example.
Anyway, I found it: it’s here, right where it is supposed to be: https://docs.openhab.org/administration/logging.html#karaf-console
Thanks again for all the help.
Regards,
Joe