Unable to write to a log file using Log4j

Hello All,

I am unable to write to a log file using Log4j jars. I imported all log4j jars onto the project. When i execute my script, i got the following exception.

Exception in thread “main” java.lang.NoClassDefFoundError: org/slf4j/Logger

Default Asked on August 14, 2016 in Selenium WebDriver.
Add Comment
  • 4 Answer(s)

    Kaarthiiik, You seem to be missing some Jar files. Please go through the tutorials here to get the complete list of Log4J file

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

    Professor Answered on August 16, 2016.
    Add Comment

    Ggg

    Default Answered on September 4, 2016.
    Add Comment

    See you need to download log4j.jar…..then set the path…or enable it to your project.
    Again download log4j.xml from google.

    public class myclass{

    void myfile(){

    Logger log=logger.getlogger(“myclass”)
    PropertyConfigurator.configure(“log4j.properties”);
    Webdriver driver=new firefox();
    driver. get(“http://google.com”);
    }
    }…hope this will help.

    }

    Default Answered on September 4, 2016.
    Add Comment

    hi guys,

    Seems I have a similar problems with this log4j. When I run the script it does create a logfile.log but that log is empty.
    Is there any problem with that??

    Default Answered on February 3, 2017.
    Add Comment
  • Your Answer

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