I am using log4net for creating execution logs of test cases which are created and being executed using Selenium Webdriver in C#. I was able to implement the logging functionality but I am facing an issue with the same or you can say I have a query related to this logging feature. I have seen that every web link which provides information about this logging has shown it in a way like:

driver = new ChromeDriver();
logger.Info("Browser is launched");
logger.Info("Navigate to the URL provided by the user");
logger.Info("Maximize the window");

i.e. I have to use this line 'logger.Info' at all such places where logging is required.

Is there any way in which I can avoid using it repetitively? i.e. I use 'logger.Info' only at one places and it creates logs for the whole test case execution automatically, means I want to avoid repeating this line again and again.

Reference links (these links shows that I have repeat this code of line):-

  1. learn-automation.com

  2. toolsqa.com

  3. softwaretestinghelp.com

  4. eyecatch.no


Write some wrapper class with all the WebDrive Methods (add log messages there) and use those methods in your tests.


public class WebDriverMethods {

  public static final LOGGER = Logger.getLogger(WebDriverMethods.class.getName());
  public void click(By by) {
     //click logic

  public void type(By by,String data) {
     //sendKeys logic
     LOGGER.info(data+" data entered in "+by);

   // write all the required methods


Use above methods in your testcase to get logs for each step performed.

Not the answer you're looking for? Browse other questions tagged or ask your own question.