title: How to write a test case to verify log4j logs are generated in proper format
body: <p>I want to write a testng test case to verify that the logs (log4j) generated are following exactly the given conversion pattern from the log4j.properties file. As an example if I have conversion pattern : <code>[%d] %-5p [%t]: %m%n</code> a sample log would looks like <code>[2015-07-07 16:42:09,937] DEBUG [main]: Message 1</code> I want to make sure that the log follows the exact pattern.</p>
  
  <p>So for now what I'm doing is first read all the logs in to a String array and loop that array to find whether the expected log without the date i.e. <code>DEBUG [main]: Message 1</code> contains in the recorded.</p>
  
  <p>Is this way of testing log records is correct ?
  If you have any idea about a good way to test logs rather than this please point out.</p>