Forum Discussion

rfortune's avatar
rfortune
Contributor
13 years ago

[Resolved] Possible to clear Log Output console using Groovy

Hi there,

I'm just wondering if I can clear the log output console through a groovy method?

Cheers,
Richard
  • tech321's avatar
    tech321
    6 years ago
    com.eviware.soapui.SoapUI.logMonitor.getLogArea("Script Log").clear()

     Capital S and Capital L in "Script Log"

    then it works fine , thanks

     

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    yes - you can use

    com.eviware.soapui.SoapUI.logMonitor.getLogArea("script log").clear()

    Regards,
    Vladimir
    SmartBear Software
    • stef's avatar
      stef
      Occasional Contributor

      Actually it should be:

       

      com.eviware.soapui.SoapUI.logMonitor.getLogArea("Script log").clear()

       

      Note the capital S.

    • PramodYadav's avatar
      PramodYadav
      Contributor

      Note that below command only works if you run your tests from " Test case"  or the " Test Steps group" -> just below test case name".

       

      If you try to run below from a stand alone groovy step, this will not clear the log. Be aware! Had us wondering for few days. 

       

      com.eviware.soapui.SoapUI.logMonitor.getLogArea("script log").clear()

      • tech321's avatar
        tech321
        Contributor
        com.eviware.soapui.SoapUI.logMonitor.getLogArea("Script Log").clear()

         Capital S and Capital L in "Script Log"

        then it works fine , thanks

         

  • eurdim's avatar
    eurdim
    Occasional Contributor

    looks like the "com.eviware.soapui.SoapUI.logMonitor.getLogArea( "Script  log" )" always returns null with ReadyAPI 2.3.0, no matter if executed in groovy teststep script or as Setup Script on testcase or testsuite level

    • gauravkhurana's avatar
      gauravkhurana
      Occasional Contributor

      though they should not make such changes

       

      try with capital L it works

       

      i mean change "Scipt log" to "Script Log"

       

      com.eviware.soapui.SoapUI.logMonitor.getLogArea("Script Log").clear()

       

  • eurdim's avatar
    eurdim
    Occasional Contributor

    yes exactly that's the point: it's case sensitive and the name of the log file area has to be set exactly as it appears on the UI - unfortunately they use different versions all over the place:

    SoapUI 5.4.0: "script log"

    ReadyAPI 2.2.0: "Script log"

    ReadyAPI 2.3.0: "Script Log"

    :smileyfrustrated:

     

    another interesting question regarding this topic is why the statement

    "com.eviware.soapui.SoapUI.logMonitor.getLogArea( "..." )"

    works if executed manually via UI but fails if executed automatically via maven plugin on the CI:

    NullPointerException: Cannot invoke method getLogArea() on null object

    another post mentioned the same already guessing that it only works in the environment with a UI present, but I am curious if we really have to live with that or if there's asolution to get this working in maven as well

     

    • Nastya_Khovrina's avatar
      Nastya_Khovrina
      SmartBear Alumni (Retired)

      The "Script Log" area only applies to the GUI and not the command line. But, you can use a content of the ReadyAPI log files which are located in the C:\Users\%username%\.readyapi\logs folder by default.