The syntax of an explicit logging statement is:
Code Block |
---|
language | javascript |
---|
theme | Confluence | language | javascript |
---|
|
log <level> <expr> |
where <level> is one of info
, warn
, error
, or debug
; and <expr>
is any valid KRL expression that results in a string (or something that can be cast as a string such as a number).
...
- The log message is placed in the transaction log that is returned with the evaluation results if the
logging
pragma is on in the meta section. console log - The log message is shown in the browser's console if the ruleset returns JavaScript to a browser (see Web actions). "Logging" tab of the UI if enabled
The following example would place a string with the value of a variable named query in named query
in the log if the rule fired:
Code Block |
---|
language | javascript |
---|
theme | Confluence |
---|
language | javascript |
---|
|
fired { log debug "query:"+query }
|
The following would only log with an empty query:
Code Block |
---|
language | javascript |
---|
theme | Confluence | language | javascript |
---|
|
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.
Code Block |
---|
language | javascript |
---|
theme | Confluence |
---|
language | javascript |
---|
|
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;
}
} |
...