Forum Discussion

opaciga's avatar
opaciga
New Contributor
2 years ago

Setting log level in ReadyAPI and TestRunner

Is there an official way to change the log level when running tests with ReadyAPI and TestRunner?

 

The ReadyAPI docs on groovy scripts only mention using `log.info` to write output from scripts. I would love to be able to use `log.debug`, so that when running locally people can set their ReadyAPI instance to log debug logs but when running with TestRunner in CI we would limit logs to info only.

 

  • Hello opaciga 

     

    Is this what you are attempting?

     

    import org.apache.log4j.Level;
    import org.apache.log4j.Logger;
    
    lvl = log.getLevel();
    log.info "lvl=$lvl";
    
    log.setLevel(org.apache.logging.log4j.Level.DEBUG);
    lvl = log.getLevel();
    log.debug "lvl=$lvl";

     

     

    Regards,

    Todd

  • TNeuschwanger's avatar
    TNeuschwanger
    Champion Level 1

    Hello opaciga 

     

    Is this what you are attempting?

     

    import org.apache.log4j.Level;
    import org.apache.log4j.Logger;
    
    lvl = log.getLevel();
    log.info "lvl=$lvl";
    
    log.setLevel(org.apache.logging.log4j.Level.DEBUG);
    lvl = log.getLevel();
    log.debug "lvl=$lvl";

     

     

    Regards,

    Todd