log($message)
log($message, $arguments)
log($message, $arguments, level: $level)
Writes an entry to the application log. The level determines the severity of the log entry.
| Name | Type | Description | Mandatory | Default |
|---|---|---|---|---|
| message | String | The message to be written to the log. If arguments is also specified, placeholders in the form of {0}...{n} can be defined in the message. If the message contains a placeholder but there is no argument to fill it, {n} is written to the message in plain text. |
yes | |
| arguments | Set | Arguments to be inserted into the placeholders of message in the specified order. If no or too few placeholders are specified, then not all arguments will be used. |
no | |
| level | String | The severity of the log entry, one of debug, info, warn, error or fatal (case-insensitive). As the message may be followed by an arbitrary number of arguments, the level can only be passed as a named argument. |
no | info |
log('Hello');
Output (in log): Hello
log('Current date: {0}. Current week day: {1}', today(), today().toUserCalendar().dayOfWeek())
Output (in log): Current date: 14.02.22 16:00. Current week day: 2
log('Current date: {0}. Current week day: {1}')
Output (in log): Current date: {0}. Current week day: {1}.
Since no arguments were specified, the placeholders are not replaced and output like this.
log('Current date: {0}', today(), today().toUserCalendar().dayOfWeek())
Output (in log): Current date: 14.02.22 16:00
There are more arguments than placeholders, so the second argument is ignored.
log('Disk almost full: {0}%', $percentage, level: 'warn')
Output (in log, as a warning): Disk almost full: 95%