Outputting logs onto eclipse console when running test parr
Outputting logs onto eclipse console when running test parr
M
Posted on 08/05/2016
Hello Everyone,
Your help will be highly appreciated, I have setted up selenium grid using testNg as test framework to support parrallel test execution,
I have been able to succesfully generate logs for seperate test files by just calling below method in each tests @BeforeTest Level which is great.
However the issue I need help with is how do I ehance this method so that I can also be outputting onto eclipse console as well by just using the logs.debug(""), at the moment I am having to write System.out.println along with logs.debug() so as to write into the files generated and also to output to eclipse console.
NOTE : I am know longer using log4j.properties file.
public void initLogs(Class<?> class1){
FileAppender appender = new FileAppender(); appender.setFile(System.getProperty("user.dir") + "<FilePath>"+class1.getSimpleName()+".txt"); appender.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n")); appender.setAppend(false); appender.activateOptions(); logs = Logger.getLogger(class1); logs.setLevel(Level.DEBUG); logs.addAppender(appender); logs.debug("Log Initialized to be generated for test : " + class1.getSimpleName());
//In every test class, in the beforeTest we call the method as : initLogs(this.getClass()); }