Logging
Robot Framework log levels
Robot Framework has multiple log levels that control what is shown in the automatically generated log file.
Controlling Robot Framework log level with robot.yaml
The default Robot Framework log level is INFO
. If you want to change the log level, use the --loglevel
argument in robot.yaml
. For example, here is how you use the DEBUG
log level:
Disable all logging globally
Use the NONE
log level to disable all logging (robot.yaml
):
NOTE: The globally set log level is ignored by select keywords (FOR, WHILE and Wait Until Succeeds keywords) by design. To remove logging from these keywords you need to provide one of the below arguments. Additional information can be found here.
Parameter | Action |
---|---|
-- removekeywords all | Remove data from all keywords unconditionally. If used this will also suppress error messages logged in TRY / EXCEPT / FINALLY blocks. |
-- removekeywords for | Remove all passed iterations from FOR loops except the last one. If used in conjunction with --loglevel NONE then the last iteration will also be ignored. |
-- removekeywords while | Remove all passed iterations from WHILE loops except the last one. If used in conjunction with --loglevel NONE then the last iteration will also be ignored. |
-- removekeywords wuks | Remove all failing keywords inside BuiltIn keyword Wait Until Keyword Succeeds except the last one. If used in conjunction with --loglevel NONE then the last iteration will also be ignored. |
Use the NONE
log level in conjunction with the FOR remove keywords flag to disable all logging as well as FOR loop logging (robot.yaml
):
Disable logging for individual keywords
Use the Register Protected Keywords
keyword from the RPA.RobotLogListener
library to disable logging for individual keywords. See the example robot below.
Flatten keywords
Flattening keywords is done already when the output file is parsed initially. This can save a significant amount of memory especially with deeply nested keyword structures. The
--flattenkeywords
option flattens matching keywords. In practice this means that matching keywords get all log messages from their child keywords, recursively, and child keywords are discarded otherwise.
Remove keywords
Removing keywords is done after parsing the output file and generating an internal model based on it. Thus it does not reduce memory usage as much as flattening keywords. The
--removekeywords
option removes keywords and their messages altogether.
Logging example robot
This robot demonstrates the effect of the global log level (robot.yaml
) and shows how to disable logging for individual keywords using the RPA.RobotLogListener
library: