Is there a way to stop logging to Report / Log file?

6,963 views
Skip to first unread message

Pether Pettersson

unread,
Feb 3, 2016, 4:23:49 AM2/3/16
to robotframework-users
I am trying to prevent RF/Ride to write which keywords has been run to the Report/Logfile because i am repeating a keyword for 30 minutes, and thus the keyword will be run a lot of times.
I am aware that i can write python functions, which is what i have done before. But i am refactoring my test environment to not have these special cases in the environment as i am trying to abstract and generalize so not have one time use keywords when selling to other customers. I am sending messages through the serial port, so having it in a stand alone file isn't possible, it must have access to the connection.

As RF lacks a while loop other then Wait until Keyword Succeeds i am stuck in using that, running a keyword, and in that keyword running a keyword that checks the time elapsed, if < 30min we fail and repeat keyword, else we succeed.
I have turned off logging to console as it is simple, but haven't found a way to stop the keywords to be logged.

Hi-Fi

unread,
Feb 4, 2016, 12:11:50 AM2/4/16
to robotframework-users
If you want to remove just single keywords from loop, you can exclude those from output files: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#removing-and-flattening-keywords.

If you want to disable complete logging, you just need to set --loglevel to NONE (http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#log-levels)

Vernon Crabtree

unread,
Apr 26, 2017, 6:41:10 AM4/26/17
to robotframework-users
I created the keywords "Disable keyword logging" and "Enable keyword logging" in a python library like this:

from robot.libraries.BuiltIn import BuiltIn
from robot.output.logger import LOGGER
import types

def _nothing(*args, **kwargs):
    pass

def disable_keyword_logging(self):
    self._logging_methods = (LOGGER.start_keyword, LOGGER.end_keyword)
    LOGGER.start_keyword = types.MethodType(_nothing,LOGGER)
    LOGGER.end_keyword = types.MethodType(_nothing,LOGGER)

def enable_keyword_logging(self):
    LOGGER.start_keyword, LOGGER.end_keyword = self._logging_methods


You still need to use the loglevel to remove information logged by the keywords.

Jayson Panganiban

unread,
Apr 26, 2017, 10:06:53 AM4/26/17
to robotframework-users
use --removekeywords WUKS to remove "wait until keyword succeeds" logs

Pekka Klärck

unread,
Apr 26, 2017, 10:59:56 AM4/26/17
to Vernon Crabtree, robotframework-users
Hi,

Clever solution! The problem with it is that it uses Robot's internal
modules and they are subject to change especially in major releases.
It ought to be possible to re-implement these keywords if that
happens, though.

The best solution would be adding a built-in support for the framework
to disable logging keyword start and end. The end result is very close
to what `--flattenkeywords` does, and perhaps this functionality could
be enabled using keyword tags like:

*** Keywords ***
Example
[Tags] robot:flatten
Some keyword
Another keyword

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

Vernon Crabtree

unread,
Apr 26, 2017, 3:41:22 PM4/26/17
to robotframework-users, vernon.b...@gmail.com
Correct - using internals is not the best long-term solution.

I know there are well-documented options to flatten certain keywords in different ways (including WUKS).  I am not sure how these work under-the-covers, but I think the keywords are first logged to the intermediate output file and then filtered out again at the end (I could be wrong).
My reason for wanting to disable logging was primarily for performance but also to try to get a clean log - so it is essential to stop the logging in the first place.

I like the idea of Robot not logging when there is a certain tag.  
  1) I have not seen this tag form before (with 'robot:').  Are there other uses?
  2) Would this work for both user-defined and library keywords?
  3) Can this be made so that it applies to all keywords called by the user/library keyword as an option (maybe have 2 tags something like: "robot:flatten" and "robot:flatten-recursive"

I am happy to help out with design/implementation - please point me in the right direction to start.

I also wanted to be able to programmatically re-enable the logging when something goes wrong for better error handling and reporting useful information - although I have not done so yet.
What I have not yet implemented in my small trial library is an option to enable all logging for diagnostic purposes.  If we can build this into Robot Framework I would want to add this somehow too (maybe a command-line option to not flatten).
.

Александр Илюшкин

unread,
Apr 27, 2017, 3:32:55 AM4/27/17
to robotframework-users
Robot Framework logging system using the hardcoded output.xml file which is basically an xml representation of the log. This is a basic file for all log formatters.
When RF ends test execution it execute its own inner report generator. This generator gets output.xml and produce report.html and log.html files based on output.xml.

Giving your execution additional parameters like flatten / wuks or anything like that actually works only on the html log generator, BUT NOT on the output.xml.
That's why the only one possible way to remove anything from your logs is to remove this information from the output.xml file (which is generated on the fly, parallel to the test execution procees).

You can do this by setting the log level to NONE.

Now how to remove any information logged by a certain keyword and keywords called behind it: 
we solved this problem by creating a listener plus using a custom keyword tag.

listener looks for this custom tag, for instance no_logging, and if it sees this, it just sets log level to NONE (saving returned previous log level to a context variable).
end_keyword method returns log level to the old log level. 

to be able to turn it off once from the top level keyword, you should firstly save your keyword name and turn back the old log level if you meet this top level keyword name once again (not other names), or you will be getting logs if any "not logged" keyword meets under your top level keyword.

But firstly try to use the flatten keywords argument.

среда, 3 февраля 2016 г., 12:23:49 UTC+3 пользователь Pether Pettersson написал:

Pekka Klärck

unread,
Apr 28, 2017, 3:08:08 AM4/28/17
to Vernon Crabtree, robotframework-users
2017-04-26 22:41 GMT+03:00 Vernon Crabtree <vernon.b...@gmail.com>:
> Correct - using internals is not the best long-term solution.
>
> I know there are well-documented options to flatten certain keywords in
> different ways (including WUKS). I am not sure how these work
> under-the-covers, but I think the keywords are first logged to the
> intermediate output file and then filtered out again at the end (I could be
> wrong).
> My reason for wanting to disable logging was primarily for performance but
> also to try to get a clean log - so it is essential to stop the logging in
> the first place.

I assume that with "stop the logging" you mean stopping writing
`<kw></kw>` tags, which is essentially the same what using `--flatten`
does after the fact, and not stopping logging keyword messages? The
latter is something you can already now accomplish by using the
special log level `NONE`, and I'd like to keep this flattening and
actual message logging separate also in the future.

> I like the idea of Robot not logging when there is a certain tag.
> 1) I have not seen this tag form before (with 'robot:'). Are there other
> uses?

Such special keyword tags aren't yet widely used. The best example is
`robot:no-dry-run` that was added in RF 3.0.2 [1]. At the same time we
decided to start using the `robot:` prefix with all such tags.

[1] https://github.com/robotframework/robotframework/issues/2528

> 2) Would this work for both user-defined and library keywords?

Yes, although with normal library keywords it wouldn't really have any
effect. I think this functionality should be applied only to the
keywords executed by the keyword containing the tag, and in this case
only library keywords executing other keywords via
`BuiltIn.run_keyword` would benefit. This can be discussed, though.

> 3) Can this be made so that it applies to all keywords called by the
> user/library keyword as an option (maybe have 2 tags something like:
> "robot:flatten" and "robot:flatten-recursive"

In my opinion it should automatically be applied to all keywords below
the keyword that has the tag. Additional tag to disable flattening
(e.g. `robot:no-flatten`) could be considered but I doubt it would be
useful.

> I am happy to help out with design/implementation - please point me in the
> right direction to start.

The first step is submitting an issue. We can then continue discussing
about the design in its comments and have everything in the same
place.

> I also wanted to be able to programmatically re-enable the logging when
> something goes wrong for better error handling and reporting useful
> information - although I have not done so yet.

As I already wrote, I'd like to keep flattening the keyword structure
(i.e. not writing `<kw></kw>` tags) and general logging separate. When
you flatten, you don't lose any information except the original
keyword structure. If you disable logging altogether, then valuable
information can be lost, but I'd like to keep that separate from
flattening.

> What I have not yet implemented in my small trial library is an option to
> enable all logging for diagnostic purposes. If we can build this into Robot
> Framework I would want to add this somehow too (maybe a command-line option
> to not flatten).

If flattening is enabled with keyword tags, you could specify a tag
using a variable like

*** Variables ***
${FLATTEN} robot:flatten

*** Keywords ***
Example
[Tags] ${FLATTEN}

and then override it from the command line like `--variable FLATTEN:no-flatten`.

Cheers,
.peke

Pekka Klärck

unread,
Apr 28, 2017, 3:13:38 AM4/28/17
to Александр Илюшкин, robotframework-users
2017-04-27 10:32 GMT+03:00 Александр Илюшкин <positi...@gmail.com>:
> Robot Framework logging system using the hardcoded output.xml file which is
> basically an xml representation of the log. This is a basic file for all log
> formatters.
> When RF ends test execution it execute its own inner report generator. This
> generator gets output.xml and produce report.html and log.html files based
> on output.xml.

This is exactly correct. Having a way to tell the framework not to
write some information into the output.xml file already during the
execution would be a nice new feature. As I commented in my previous
reply to this thread, I'd like to keep logging messages by keywords
and the framework writing `<kw></kw>` tags into the output.xml
separate, though.

Removing the `<kw></kw>` tags is effectively what `--flattenkeywords`
currently does, but at the moment it doesn't affect the output.xml
file generated during test execution. We could obviously consider
changing that logic too.

Александр Илюшкин

unread,
Apr 28, 2017, 5:45:46 PM4/28/17
to Pekka Klärck, robotframework-users
That's sounds awesome, Pekka, thank you for one of the most powerful test frameworks.

пт, 28 апр. 2017 г. в 10:13, Pekka Klärck <pe...@iki.fi>:
--

С уважением,
Илюшкин Александр.
E-mail: positi...@gmail.com

Pekka Klärck

unread,
May 2, 2017, 7:37:34 AM5/2/17
to Александр Илюшкин, robotframework-users
2017-04-29 0:45 GMT+03:00 Александр Илюшкин <positi...@gmail.com>:
> That's sounds awesome,

Yeah, I assume it would be a nice feature in cases where you have
deeply nested user keywords. Should be too complicated to implement
either. If someone is interested to look at it, we ought to be able to
get it into RF 3.1. My current plan is to start RF 3.1 work once we
get Selenium2Library with Python 3 support out.

> Pekka, thank you for one of the most powerful test
> frameworks.

Thanks for kind works!

Serafim Marques

unread,
Apr 8, 2020, 6:04:18 AM4/8/20
to robotframework-users
Hello! 
I'm sorry for digging up this old thread, but I would like to know if there was some new developments regarding this matter in the recent release, mostly related to have a way to tell the framework not to
write some information into the output.xml file during the execution. Currently in my tests the output.xml can become gigantic and even though it can be parsed using rebot, it can only be done after Robot finishes its work. Log file is fine because I'm using the --flattenkeywords, the output.xml is the issue.

Thank you!
Best Regards,
SM

Pekka Klärck

unread,
Apr 8, 2020, 7:22:57 AM4/8/20
to fim.ma...@gmail.com, robotframework-users
Hi,

Unfortunately this situation hasn't got any better lately. We do have
an issue about possibility to control logging of executed keywords,
though:
https://github.com/robotframework/robotframework/issues/2603

That issue isn't trivial to implement but not super complicated
either. If someone is interested to look at implementing it, I'd be
happy to help. I doubt I have time for that personally as there are
even more important features that need my attention.

Cheers,
.peke

ke 8. huhtik. 2020 klo 13.04 Serafim Marques (fim.ma...@gmail.com)
kirjoitti:
> --
> 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 view this discussion on the web visit https://groups.google.com/d/msgid/robotframework-users/e6e66b00-fdf3-4abd-a5fe-f894a7dced64%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages