Note: You are looking at a static snapshot of documentation related to Robot Framework automations. The most recent documentation is at https://robocorp.com/docs

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:

tasks: Default: command: - python - -m - robot - --report - NONE - --outputdir - output - --logtitle - Task log - --loglevel - DEBUG - tasks.robot

Disable all logging globally

Use the NONE log level to disable all logging (robot.yaml):

tasks: Default: command: - python - -m - robot - --report - NONE - --outputdir - output - --logtitle - Task log - --loglevel - NONE - tasks.robot

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.

ParameterAction
-- removekeywords allRemove data from all keywords unconditionally. If used this will also suppress error messages logged in TRY / EXCEPT / FINALLY blocks.
-- removekeywords forRemove 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 whileRemove 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 wuksRemove 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):

tasks: Default: command: - python - -m - robot - --report - NONE - --outputdir - output - --logtitle - Task log - --loglevel - NONE - --removekeywords - for - tasks.robot

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:

*** Settings *** Documentation Demonstrates the effect of global log level (robot.yaml). ... Shows how to disable logging for individual keywords. ... https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#log-levels Library RPA.Browser.Selenium Library RPA.RobotLogListener Task Teardown Close All Browsers *** Tasks *** Use global log level (robot.yaml) Log in # # Log level: INFO (default) # ----------------------------------------------------------- # ${username} = BuiltIn . Set Variable maria # # ${password} = BuiltIn . Set Variable thoushallnotpass # # RPA.Browser.Selenium . Input Text username, ${username} # Typing text 'maria' into text field 'username'. # # RPA.Browser.Selenium . Input Password password, ${password} # Typing password into text field 'password'. # Temporally setting log level to: NONE # Log level changed from NONE to INFO. # # Log level: NONE (disable detailed logging) #------------------------------------------------------------ # ${username} = BuiltIn . Set Variable maria # # ${password} = BuiltIn . Set Variable thoushallnotpass # # RPA.Browser.Selenium . Input Text username, ${username} # # RPA.Browser.Selenium . Input Password password, ${password} Use RPA.RobotLogListener to disable logging for individual keywords Register Protected Keywords Log in Log in # # ${username} = BuiltIn . Set Variable maria # # ${password} = BuiltIn . Set Variable thoushallnotpass # # RPA.Browser.Selenium . Input Text username, ${username} # # RPA.Browser.Selenium . Input Password password, ${password} *** Keywords *** Log in Open Available Browser https://robotsparebinindustries.com/ ${username}= Set Variable maria ${password}= Set Variable thoushallnotpass Input Text username ${username} Input Password password ${password}
Last edit: May 5, 2022