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

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.

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

*** 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}

*** 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}

*** Tasks ***
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}

Learn more about the libraries mentioned on this page: