The syntax of an explicit logging statement is:

<expr>.klog(<message>)

where <expr> is any valid KRL expression and <message> results in a string (or something that can be cast as a string such as a number).

Explicit logging places the log message in two places:

The following example would place a string with the value of a variable named query in the log if the rule should fire:

pre {
  query = event:attr("query")
  fire = function(query){
    result = shouldFire(query);
    
  }()
fired { log debug "query:"+query } 

The following would only log with an empty query:

fired { log debug "Empty query" if(query like "^$") }

The following rule is selected when an http:post() event is seen with a status code indicating an error. The error is logged and then processing is stopped. 

rule r3 is active {
  select when http post label re#ex# status_code re#([45]\d\d)# setting (status)
  noop();
  fired {
    log error <<Error: #{status}: #{event:attr("status_line")}>>
    last;
  }
} 

Another approach to logging would use explicit error handling.

See Debugging KRL for more information on debugging tools.