How to integrate Log4j with TestNG?

Have no idea how to integrate Log4j with TestNg. Plz help

Default Asked on May 12, 2015 in Selenium WebDriver.
Add Comment
  • 3 Answer(s)

    Pls refer to the tutorial
    http://www.toolsqa.com/selenium-webdriver/log4j-introduction/

    Train Answered on May 13, 2015.

    Not clear about how to start with. In the link does not explain of how to integrate log4j with TestNg.

    on May 13, 2015.
    Add Comment

    Well the above answer should have been sufficient if you read through the chapters, but as you are looking for exact thing, you can take a look here.

    http://www.toolsqa.com/selenium-webdriver/log4j-logging/

    Virender

    Professor Answered on May 13, 2015.

    I actually want the log messages of log4j to be displayed in the TestNG output , which is currently not working.

    on May 13, 2015.

    Sharon, You have to use the Reporter class instead of Log4J to pass on the logs in TestNG. You can also Implement the IReporter interface to have your custom reporter class.

    We can also direct Log4J logs to Reporter by writing a small wrapper. I Dont have a code for this as of now, but can come up with one soon.

    Thanks
    Virender

    on May 14, 2015.
    Add Comment

    Hi Sharon

    If Log4j functionality is still not working in your framework. Please share your Log4j Code which is not working will rectify that one.

    Train Answered on May 17, 2015.

    Hi,

    Actually my code works absolutely fine.
    But the lines we print using Log4j eg:  Log.info(“New driver instantiated”);
    Does not get reflected in TestNG report.
    But using line Eg: Reporter.log(“Clicking on daily link”, true); reflects in TestNG(which is not an log4j reporting)
    I want to know how to print the log statement in TestNG.

    on May 17, 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.