5.5 Logging

We use the lgr package for logging and progress output.

5.5.1 Changing mlr3 logging levels

To change the setting for mlr3 for the current session, you need to retrieve the logger (which is a R6 object) from lgr, and then change the threshold of the like this:

The default log level is "info". All available levels can be listed as follows:

## fatal error  warn  info debug trace 
##   100   200   300   400   500   600

To increase verbosity, set the log level to a higher value, e.g. to "debug" with:

To reduce the verbosity, reduce the log level to warn:

lgr comes with a global option called "lgr.default_threshold" which can be set via options() to make your choice permanent across sessions.

Also note that extension packages such as mlr3tuning define their own logger which inherits from the mlr3 logger. To disable the output from mlr3, but keep the output from mlr3tuning, first reduce the verbosity for the parent logger mlr3, then restore verbosity for the child logger mlr3tuning:

5.5.2 Redirecting output

Redirecting output is already extensively covered in the documentation and vignette of lgr. Here is just a short example which adds an additional appender to log events into a temporary file in JSON format:

## WARN  [08:23:02.049] this is a warning from mlr3
## {"level":300,"timestamp":"2020-08-07 08:23:02","logger":"mlr","caller":"eval","msg":"this is a warning from mlr3"}