package com.evs.util; import java.io.FileOutputStream; import org.apache.log4j.*; public class Log { public static Logger logger; static{ logger = Logger.getLogger(Log.class); //Generate pattern string for pattern layout /* String pattern = "%n%nClassname of caller: %C %n"; pattern += "Date : %d{ISO8601} %n"; pattern += "Location : %l %n"; pattern += "Log Message: %m %n %n"; */ /* String pattern = "%n%nClassname of caller: | %C %n |
"; pattern += "
Date : | %d{ISO8601} %n |
"; pattern += "
Location : | %l %n |
"; pattern += "
Log Message: | %m %n %n |
"; */ /* String pattern = "
%n%nClassname of caller: | %C %n
"; pattern += "
Date :
%d{ISO8601} %n
"; pattern += "Location :
%l %n
"; pattern += "Log Message:
%m %n %n
"; */ /* String pattern = "
Msg | %m %n %n | "; pattern += "%n%nClass | %C %n | "; pattern += "Loc | %l %n | "; pattern += "Date | %d{ISO8601} %n |
---|
"; */ /* String pattern = "
Log4J Log MessagesMsg | %m %n %n | "; pattern += "%n%nClass | %C %n | "; pattern += "Loc | %l %n | "; pattern += "Date | %d{ISO8601} %n |
---|
"; */ /* String pattern = "
Log4J Log Messages%d{ISO8601} %n | "; pattern += "%C %n | "; pattern += " %l %n | "; pattern += " %m %n %n |
"; */ /*String pattern = "
Log4J Log Messages Date: %d{ISO8601} %n "; pattern += "class: %C %n "; pattern += "Loc : %l %n "; pattern += "Msg : %m %n %n |
"; */ //PatternLayout patternLayout = new PatternLayout(pattern); SimpleLayout simpleLayout = new SimpleLayout(); //HTMLLayout htmlLayout = new HTMLLayout(); //FileAppender fileAppender=null; //WriterAppender writerAppender = null; try { //fileAppender = new FileAppender(simpleLayout,"D:\\Voting Workspace\\Voting\\VotingLog.txt",true); // fileAppender = new FileAppender(simpleLayout,"D:\\Workspace-Eclipse\\Voting\\WebContent\\VotingLog.txt",true); // fileAppender = new FileAppender(patternLayout,"D:\\Workspace-Eclipse\\Voting\\WebContent\\VotingLog.txt",true); //fileAppender = new FileAppender(patternLayout,"D:\\Workspace-Eclipse\\Voting\\WebContent\\VotingLog1.html",true); //fileAppender = new FileAppender(patternLayout,"D:\\Workspace-Eclipse\\Voting\\WebContent\\VotingLog.txt",true); //FileOutputStream output = new FileOutputStream("D:\\Workspace-Eclipse\\Voting\\WebContent\\votingLog.html",true); // writerAppender = new WriterAppender(htmlLayout,output); } catch(Exception e) {} logger.addAppender(new ConsoleAppender(simpleLayout)); //logger.addAppender(new ConsoleAppender(patternLayout)); //logger.addAppender(fileAppender); //logger.addAppender(writerAppender); } }
No comments:
Post a Comment