Logging Issue

Hi All,

I’m trying to setup a debug logger so I can debug my rules. I have done the follow.

  1. At the top of my rule I have added

     import org.openhab.model.script.debug
    
  2. Add this to my rules.

     logDebug("debug", "Testing")
    
  3. Add this line to both logback.xml and logback_debug.xml

     <logger name="org.openhab.model.script.debug" level="DEBUG"/>
    

However I don’t get anything in either events.log or openhab.log

Can you someone point me in the right direction?

Many thanks

Are these in the same logback configuration file that’s being used by openHAB?

By default this will be either logback.xml, or logback_debug.xml, depending upon which is used when openHAB was started.

You’re looking for the one with the -Dlogback.configurationFile=... on the command line. In my case, I start using something like:

... -Dlogback.configurationFile=$ECLIPSEHOME/configurations/logback_debug.xml

so all my changes go into logback_debug.xml and the output (by default) comes out in openhab.log

PS: I don’t think the import org.openhab.model.script is needed. I’ve never had to do that.

agree w @guessed re the import.

I use multiple logs for different zones in my house.

So I have defined both an appender and a logger for each of those. For brevity, only a couple of examples.

The appender sets the log file name, entry formatting and retention policy.

Note that the logger references a specific appender to do its work and says to which (very loosely speaking)
openhab logging “domain” the logger applies.

In my case the “modules” are the log references files for each of the rooms in question. I.e,


see below for complete entry

org.openhab.model.script.KITCHEN
org.openhab.model.script.LIVING

In my kitchen rules file, I write debug messages to the kitchen.log file (spec’d in the appender), like so:


logDebug("KITCHEN","message I want in the log")

Similarly in my living room pertinent rules:

logDebug("LIVING","message I want in the log")

Less intense logging levels appear in the kitchen.log also (ie logError () logInfo() )

Here are the complete entries from my logback_debug.xml file for kitchen and living room logging.

....
    

        ${openhab.logdir:-logs}/kitchen.log
        
            
            ${openhab.logdir:-logs}/rulelog-%d{yyyy-ww}.log.zip
            
            30
        
        
            %d{yyyy-MM-dd HH:mm:ss} - %-5level %logger{30}[:%line]- %msg%n
        
    
    
        ${openhab.logdir:-logs}/living.log
        
            
            ${openhab.logdir:-logs}/rulelog-%d{yyyy-ww}.log.zip
            
            30
        
        
            %d{yyyy-MM-dd HH:mm:ss} - %-5level %logger{30}[:%line]- %msg%n
        
    

   
    
        
    


    
        
    

...

Hope this helps.

This works now. Thanks for all your help.