Rule trigger visible in log viewer

Hey Guys,

I got 2 questions please.

  • Is there a easy way to check if a rule has been triggered, what do u suggest?
  • Is there a way to “post” the rule name in the log when it triggers?
    i see my event beeing triggered, i see my lights go on and i find such info in my log.
    But there is nothing for me visible in the logs to see that all these items are linked in some way.
    most adviseable would be my rule title.
2018-11-14 16:53:00.009 [vent.ChannelTriggeredEvent] - astro:sun:home:set#event triggered START

2018-11-14 16:53:00.058 [ome.event.ItemCommandEvent] - Item 'Timeroutdoor' received command ON

2018-11-14 16:53:00.069 [ome.event.ItemCommandEvent] - Item 'Buitenvoordeur' received command ON

2018-11-14 16:53:00.086 [ome.event.ItemCommandEvent] - Item 'Buitenzijgevel' received command ON

2018-11-14 16:53:00.105 [vent.ItemStateChangedEvent] - Buitenvoordeur changed from OFF to ON

2018-11-14 16:53:00.110 [vent.ItemStateChangedEvent] - Buitenzijgevel changed from OFF to ON
rule "Sunset Buitenverlichting aan"
when
      Channel 'astro:sun:home:set#event' triggered START
then 
      Timeroutdoor.sendCommand(ON)
      
end

Thanks in advance!

This will log a message in openhab.log.

rule "Sunset Buitenverlichting aan"
when
      Channel 'astro:sun:home:set#event' triggered START
then 
      logInfo("sunset-rule", "Sunset start event triggering outside light on")
      Timeroutdoor.sendCommand(ON)
end
1 Like

logInfo can be used anywhere in a rule, and good for troubleshooting rules especially when your trying to find what part of the rule is causing it to break.

@mhilbush beat me to it.:joy:

2 Likes

Here’s a link, took a minuet to find, that shows examples for rule logging and logging to a separate file. https://www.openhab.org/docs/administration/logging.html#karaf-console

1 Like

Both very much thank you!
this does give me some questions.

Is my thinking correct when i say that this:

rule "Sunset Buitenverlichting aan"
when
      Channel 'astro:sun:home:set#event' triggered START
then 
      logInfo("sunset-rule", "Sunset start event triggering outside light on")
      Timeroutdoor.sendCommand(ON)
      
end

needs to be this:

rule "Sunset Buitenverlichting aan"
when
      Channel 'astro:sun:home:set#event' triggered START
then 
      logInfo("Home.rules", "Sunset start event triggering outside light on")
      Timeroutdoor.sendCommand(ON)
      
end

if i get it right… then the documentation says that the rules file needs to be defined “in the first part” of the “then” so: Home.rules

or am i getting this wrong?

I think your correct but you can always test the rule by replacing the when item with a proxy switch (so your not waiting all day) and test both ways. It’s possible the output of logInfo, from within a rule, will display whatever you have in " ".

Yep, you can put whatever you want in the first arg to logInfo, logDebug, logWarn, etc.

1 Like

Thought you could but wasn’t 100% sure, hate to give knee jerk comments on assumption.:smiley:

Thanks