1. 程式人生 > >Selenium+java分層(六)

Selenium+java分層(六)

log4j.rootLogger = INFO,Test,CONSOLE log4j.appender.Test.Threshold=INFO log4j.appender.Test.encoding=UTF-8 log4j.appender.Test = org.apache.log4j.DailyRollingFileAppender #日誌輸出路徑,可以寫相對路徑 log4j.appender.Test.File=E:/Rocheng/UIAutoResult/Log/logtest.log log4j.appender.Test.ImmediateFlush=true log4j.appender.Test.DatePattern='_'yyyy-MM-dd log4j.appender.Test.layout=org.apache.log4j.PatternLayout log4j.appender.Test.layout.ConversionPattern=%d %-5p [%c{1}] %m %n log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender log4j.appender.Threshold=INFO log4j.appender.CONSOLE.Target=System.out log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p [%c{1}] %m %n 3.Log的程式碼如下 publicclass Log {     private static Logger Log = Logger.getLogger(Log.class.getName());     public static void startTestCase(String sTestCaseName){         PropertyConfigurator.configure("log4j.properties");         Log.info("****************************************************************************************"
);
        Log.info("$$$$$$$$$$$$$$$$$$$$$                 "+sTestCaseName"       $$$$$$$$$$$$$$$$$$$$$$$$$");         Log.info("****************************************************************************************");         }     public static void endTestCase(String sTestCaseName){         PropertyConfigurator.configure
("log4j.properties");
        Log.info("XXXXXXXXXXXXXXXXXXXXXXX             "+"-E---N---D-"+"             XXXXXXXXXXXXXXXXXXXXXX");         }     public static void info(String message) {             PropertyConfigurator.configure("log4j.properties");             Log.info(message);     } }