Extent Reports: Logs are Getting Appended on to a Single Test Case in the Report
<p>i am Unable to Have separate Logs/entries for Different Test Cases. i.e Logs are Getting Appended on to a Single Test Case in the Extent Report generated. 
Using Extent Report Version 2.41.1..</p>

<p>The Report Sample: <a href="https://i.stack.imgur.com/Rcdt8.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/Rcdt8.jpg" alt="Extent Report Logs Geting Appended to Single Test Case"></a></p>

<p>MY Code Goes like This:</p>

<pre><code>    Base Class of TestNG:

  public static ExtentReports report;
  public static ExtentTest logger;

  @BeforeSuite
  @Parameters({"BrowserName"})
  public void beforeSuite(@Optional("Firefox") String BrowserName) 
  {
      date = new Date();
      SimpleDateFormat ft = new SimpleDateFormat ("dd-MM-yyyy");
      String TodaysDate = ft.format(date);
      prop = ResourceBundle.getBundle("DataFile");
      Driver = Browser_Factory_FSQA_Class.getBrowser(BrowserName);
      path = "//home//workspace//....//FSQA.ExtentReports//FSQA_ExtentReport_" + TodaysDate;
      File f=new File(path);
      if(!f.exists())
      {
          report = new ExtentReports(path);
      }
  }
  @BeforeTest
  @Parameters({"BrowserName"})
  public void SetUpConfig(@Optional("Firefox") String BrowserName)
  {
     report = new ExtentReports(path, false,DisplayOrder.NEWEST_FIRST);
     report.loadConfig(new File("//home//......//extent-config.xml"));
     report.addSystemInfo("Build-Tag", prop.getString("Build-Tag"))
                .addSystemInfo("Selenium ", prop.getString("SelVer"))
                .assignProject(prop.getString("Application"))
                .addSystemInfo("Envirnoment", prop.getString("AppEnvirnoment"))
                .addSystemInfo("Extent", prop.getString("ExtRpVer"));
     logger = report.startTest(this.getClass().getSimpleName());
     logger.log(LogStatus.INFO,this.getClass().getSimpleName() +" will Run on "+ BrowserName +" Browser");
     Driver.get(prop.getString("URL"));
     Driver.manage().window().maximize();
     Driver.manage().window().maximize();
     Driver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS);
  }
  @AfterMethod(alwaysRun=true)
  public void afterMethod(ITestResult result) throws IOException
  {
    try
    { 
        if(result.getStatus()==ITestResult.FAILURE)
        {
            String res = captureScreenshot(Driver, result.getName());
            String image= logger.addScreenCapture(res);
            System.out.println(image);
            String TestCaseName = this.getClass().getSimpleName() + " Test Case Failure and Title/Boolean Value Failed";
            logger.log(LogStatus.FAIL, TestCaseName  + logger.addScreenCapture(res));
        }
        else if(result.getStatus()==ITestResult.SUCCESS)
        {
            logger.log(LogStatus.PASS, this.getClass().getSimpleName() + " Test Case Success and Title Verified"); 
        }
        else if(result.getStatus()==ITestResult.SKIP)
        {
            logger.log(LogStatus.SKIP, this.getClass().getSimpleName() + " Test Case Skipped");
        }
    }
    catch(Throwable t)
    {
        logger.log(LogStatus.ERROR,t.getMessage());
        }      
      }

  public String captureScreenshot(WebDriver Driver, String TestName)
    {
   try 
    {
            date = new Date();
        SimpleDateFormat ft = new SimpleDateFormat ("dd_MM_yyyy");
        String TodaysDate = ft.format(date);
            TakesScreenshot ts=(TakesScreenshot)Driver;
        File source=ts.getScreenshotAs(OutputType.FILE);
        Sc_Destination = prop.getString("SC_Dest")+TestName+"__"+TodaysDate+".png";
        FileUtils.copyFile(source,new File(Sc_Destination));
        logger.log(LogStatus.FAIL,image, "Title verification");*/
        return Sc_Destination;
    } 
    catch (Exception e)
    {
        System.out.println("Exception while taking screenshot "+e.getMessage());
    } 
  return Sc_Destination;
}

  @AfterTest(alwaysRun=true)
public void AfterTest()
{
    Driver.close();
    report.endTest(logger);
    report.flush();
}

  @AfterSuite
 public void AfterSuite()
{
      report.close();
      Driver.quit();
}
</code></pre>

<p>My Tests are Separate Clases which Extends this Base Class:
TC1:</p>

<pre><code>public classTC1 extends BaseTestNG
  {
  @Test(groups = {"Happy_Path"} , description="TC1")
public void TestCase1() throws InterruptedException, Exception
  {
      logger.log(LogStatus.INFO, " Test Case2 Block Entered");
      Thread.sleep(4000); 
      ......
              ......
      logger.log(LogStatus.INFO, "Assert Flag Received");
      Thread.sleep(4000); 
      Assert.assertTrue(AssertFlag);        
  }
  }
</code></pre>

<p>TC2:</p>

<pre><code>public classTC2 extends BaseTestNG
  {
  @Test(groups = {"Happy_Path"} , description="TC2")
public void TestCase2() throws InterruptedException, Exception
  {
      logger.log(LogStatus.INFO, " Test Case2 Block Entered");
      Thread.sleep(4000); 
      ......
              ......
       logger.log(LogStatus.INFO, "Assert Flag Received");
      Thread.sleep(4000); 
      Assert.assertTrue(AssertFlag);        
  }
  }
</code></pre>

<p>I am Using POM Classes along with TestNG and running the Testcases using testng.xml.</p>

<p>I am able to generate the Extent Report but unable to Differentiate Between TC1 &amp; TC2 Logs i.e all test Case logs are getting appended to single TestCase as shown in the Above Screen Shot.</p>

<p>I want each Test Case Logs/Entry in separate rows in the Extent Reports.</p>

<p>Can Anyone please rectify the mistake in my code and help me out.</p>

<p>Thanks in Advance!!!</p>