0

I have a scenario class, which has list of Test cases. Is there any way that I can save each Test case execution to separate file with name: TestCaseName.log?

I have done this before with java.util.logging by adding file handler in the code, but have no idea how to do this with Log4j.

Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
mrk2
  • 797
  • 3
  • 9
  • 20
  • 3
    @RKC Your edit should have been rejected. Do not, ever, add "Pls Help" to the end of someone's answer. I'll be looking into who approved that edit and potentially flagging for some special moderator attention. – Duncan Jones Apr 14 '14 at 08:54

2 Answers2

0

You can do this by configuring a separate org.apache.log4j.RollingFileAppender for each Test case class. You can check the link http://logging.apache.org/log4j/2.x/manual/configuration.html for configuring this.

Priyesh
  • 2,041
  • 1
  • 17
  • 25
  • There is only one class "TestCase", I need to separate logging for each instance of this class – mrk2 Apr 14 '14 at 09:32
0

Task was completed by adding RollingFileAppenders programmatically, just like in this example: http://howtodoinjava.com/2013/04/08/how-to-programmatically-configure-appenders-in-log4j/

mrk2
  • 797
  • 3
  • 9
  • 20