From: <cm...@us...> - 2007-03-30 21:28:55
|
Revision: 450 http://svn.sourceforge.net/obo/?rev=450&view=rev Author: cmpich Date: 2007-03-30 14:28:56 -0700 (Fri, 30 Mar 2007) Log Message: ----------- removed appender and ensured that if no log4j file being found not to call the log4j Configurator Modified Paths: -------------- phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java Modified: phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2007-03-30 21:27:06 UTC (rev 449) +++ phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2007-03-30 21:28:56 UTC (rev 450) @@ -2,8 +2,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import org.apache.log4j.PatternLayout; -import org.apache.log4j.RollingFileAppender; import org.apache.log4j.xml.DOMConfigurator; import org.springframework.web.servlet.DispatcherServlet; import phenote.config.Config; @@ -15,7 +13,6 @@ import javax.servlet.ServletContext; import javax.servlet.ServletException; import java.io.File; -import java.io.IOException; public class PhenoteServlet extends DispatcherServlet { @@ -29,7 +26,7 @@ * Initialization of this servlet upon server startup. * Happens when <load-on-startup> tag in the web.xml is set to '1'. * - * @param config + * @param config ServletConfig * @throws ServletException */ public void init(ServletConfig config) throws ServletException { @@ -80,36 +77,20 @@ if (log4jFileName != null) { DOMConfigurator.configure(log4jFileName); } - addRootAppender(); } private String getLog4JFile() { File log4jFile = new File(webInfDir, LOG4J_FILE_NAME); String log4jFileName = log4jFile.getAbsolutePath(); - if (!log4jFile.exists()) - System.out.println("Cannot find log4j file: " + log4jFileName); + if (!log4jFile.exists()){ + LOG.info("Cannot find the log4j file: " + log4jFileName ); + LOG.info(" Log4j is not configured in this servlet. Use App servers configuration " + + "make sure you have a log4j.properties file in the classes directory."); + return null; + } return log4jFileName; } - private void addRootAppender() { - Logger rootLogger = Logger.getRootLogger(); - String logFileName = "phenote.log"; - File file = new File(webInfDir, logFileName); - String absoluteFilePath = file.getAbsolutePath(); - RollingFileAppender appender = null; - try { - String logFilePattern = "%d [%t] %-5p %c{2} - %m%n"; - appender = new RollingFileAppender(new PatternLayout(logFilePattern), absoluteFilePath); - appender.setMaximumFileSize(1 * 1024 * 1024); - appender.setAppend(true); - appender.setMaxBackupIndex(10); - } catch (IOException e) { - e.printStackTrace(); - } - rootLogger.addAppender(appender); - } - - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |