How to stop [ ERROR ], [ WARN ] log prints in console while running robot framework

1,338 views
Skip to first unread message

masthan chowdary

unread,
Nov 8, 2017, 3:43:45 PM11/8/17
to robotframework-users
Hi all,

I am using python logging module for logging purpose and i am storing those logs in to a log file using logging.FileHandler.

I am able to collect all logs in log file, but robot framework is printing  [ ERROR ], [ WARN ] logs in log file as well as in log file also.

How can i disable that option in robo to stop printing console error logs.

SAMPLE TEST CASE:

####################################
*** Test Cases ***

ROBO-LOG

        log to console   ********** TESTING LOGGING ************

        TEST_LOGGER
####################################

TEST_LOGGER function in a py file:

import logging

def TEST_LOGGER():

    logObj = logging.getLogger('tmp.log')
    test_log_handler = logging.FileHandler('/tmp/tmp.log' , mode='w')
    formatter = logging.Formatter(fmt='%(asctime)s - %(levelname)s - %(message)s')
    test_log_handler.setFormatter(formatter)
    logObj.addHandler(test_log_handler)


    logObj.setLevel(logging.DEBUG)


    logObj.debug('debug log')
    logObj.info('info log')
    logObj.warning('warning log')
    logObj.error('error log')
    logObj.critical('critical log')

CONSOLE O/P:

[root@localhost practice]# pybot -t ROBO-LOG testrobo.txt
==============================================================================
Testrobo
==============================================================================
ROBO-LOG                                                              
********** PRINTING IN CONSOLE ************
[ WARN ] warning log
[ ERROR ] error log
[ ERROR ] critical log
ROBO-LOG                                                              | PASS |
------------------------------------------------------------------------------
Testrobo                                                              | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================


HOW CAN I STOP PRINTING THOSE ERROR MESSAGES IN CONSOLE ? 


Thanks in advance,
masthan chowdary

Pekka Klärck

unread,
Nov 8, 2017, 6:45:36 PM11/8/17
to mr....@gmail.com, robotframework-users
Good question. I don't know Python's logging module well enough to
give precise help, but I assume it would be possible to somehow
disable the logging handler Robot sets to intercept logged messages.
You can see how logging is configured here:
https://github.com/robotframework/robotframework/blob/master/src/robot/output/pyloggingconf.py

If you find a solution, please share it here. If you don't, perhaps we
should make the above logging configuration somehow optional. This
also might be something we should document in the User Guide.

Cheers,
.peke
> --
> You received this message because you are subscribed to the Google Groups
> "robotframework-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to robotframework-u...@googlegroups.com.
> To post to this group, send email to robotframe...@googlegroups.com.
> Visit this group at https://groups.google.com/group/robotframework-users.
> For more options, visit https://groups.google.com/d/optout.



--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Vikas Kumar

unread,
May 21, 2020, 8:52:42 AM5/21/20
to robotframework-users
Do we have the solution for the WARN and ERROR to Supress them at Console and then not to be included in logs?
Reply all
Reply to author
Forward
0 new messages