[Idrs-commit] CVS: Idrs/dev/src/net/sourceforge/idrs/core/servlet ConfigInfo.java,1.4,1.5 Init.java,
Brought to you by:
bigman921
|
From: Marc B. <big...@us...> - 2004-08-30 00:57:01
|
Update of /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/core/servlet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12162/src/net/sourceforge/idrs/core/servlet Modified Files: ConfigInfo.java Init.java IdrsConfigHandler.java IdrsController.java Log Message: Added log4j support. cleaned up the logs Index: ConfigInfo.java =================================================================== RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/core/servlet/ConfigInfo.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ConfigInfo.java 29 Aug 2004 05:01:39 -0000 1.4 --- ConfigInfo.java 30 Aug 2004 00:56:07 -0000 1.5 *************** *** 65,68 **** --- 65,71 ---- String securityImp; + String loglevel; + + /** * Constructor for ConfigInfo. *************** *** 505,507 **** --- 508,525 ---- } + public String getLogLevel() { + if (loglevel == null || loglevel.trim().length() == 0) { + return "INFO"; + } else { + return loglevel.toUpperCase(); + } + } + + /** + * @param val + */ + public void setLogLevel(String val) { + this.loglevel = val; + + } } Index: Init.java =================================================================== RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/core/servlet/Init.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Init.java 29 Aug 2004 05:01:38 -0000 1.13 --- Init.java 30 Aug 2004 00:56:07 -0000 1.14 *************** *** 14,17 **** --- 14,19 ---- package net.sourceforge.idrs.core.servlet; + import org.apache.log4j.Logger; + import org.apache.log4j.Priority; import javax.servlet.http.*; import javax.servlet.*; *************** *** 42,48 **** "net.sourceforge.idrs.pool.ScriptContextPool"; SimpleDateFormat formatter; ! PrintStream log; ! PrintStream errorLog; ServletConfig svg; //JDBCInfo appDB; --- 44,52 ---- "net.sourceforge.idrs.pool.ScriptContextPool"; + + static Logger logger = (Logger) Logger.getInstance(Init.class.getName()); SimpleDateFormat formatter; ! //PrintStream log; ! //PrintStream errorLog; ServletConfig svg; //JDBCInfo appDB; *************** *** 230,234 **** scriptPooler != null ? scriptPooler : DEFAULT_SCRIPT_POOL; ! log.println("Building ScriptContextPools"); try { scriptPool = --- 234,238 ---- scriptPooler != null ? scriptPooler : DEFAULT_SCRIPT_POOL; ! logger.info("Building ScriptContextPools"); try { scriptPool = *************** *** 248,252 **** 10); } catch (Exception e) { ! e.printStackTrace(log); } } --- 252,256 ---- 10); } catch (Exception e) { ! logger.error("Could not load contexts",e); } } *************** *** 268,283 **** idrslogPath = cfg.getReportLogPath(); ! log = ! new PrintStream( ! new FileOutputStream(new File(idrslogPath + "/startup.log"))); this.svg = svg; ! log.println("Starting idrs"); ! log.println( "Date : " + (new java.sql.Date(System.currentTimeMillis())).toString()); ! log.println("-------------------------------------------------------"); ! log.println("Starting Error Log"); buildLog(); --- 272,285 ---- idrslogPath = cfg.getReportLogPath(); ! this.svg = svg; ! logger.info("Starting idrs"); ! logger.info( "Date : " + (new java.sql.Date(System.currentTimeMillis())).toString()); ! ! logger.info("Starting Error Log"); buildLog(); *************** *** 285,296 **** app = buildApplication(); ! log.println("-------------------------------------------------------"); getAppDB(); ! log.println("-------------------------------------------------------"); retrieveDocDBs(); ! log.println("-------------------------------------------------------"); //first load appDB info --- 287,298 ---- app = buildApplication(); ! getAppDB(); ! retrieveDocDBs(); ! //first load appDB info *************** *** 311,320 **** //now load all of the docs loadDocs(); ! log.println("-------------------------------------------------------"); ! log.println("-------------------------------------------------------"); //build script contexts buildScriptContexts(); ! log.println("-------------------------------------------------------"); this.digestType = cfg.getDigestType(); --- 313,322 ---- //now load all of the docs loadDocs(); ! ! //build script contexts buildScriptContexts(); ! this.digestType = cfg.getDigestType(); *************** *** 322,326 **** // System.out.println("digest pass : " + digestPass); // System.out.println("digest type: " + this.digestType); ! log.close(); } --- 324,328 ---- // System.out.println("digest pass : " + digestPass); // System.out.println("digest type: " + this.digestType); ! } *************** *** 332,340 **** int i; //temporary ! log.println("Create Application Object"); try { app = new Application(cfg.getVars()); } catch (Exception te) { ! te.printStackTrace(log); } --- 334,342 ---- int i; //temporary ! logger.info("Create Application Object"); try { app = new Application(cfg.getVars()); } catch (Exception te) { ! logger.error("Could not create application object"); } *************** *** 391,395 **** protected void loadDocs() throws Exception { net.sourceforge.idrs.pool.RepPool pool; ! log.println("Loading Docs"); String name = ""; //String reportPool; --- 393,397 ---- protected void loadDocs() throws Exception { net.sourceforge.idrs.pool.RepPool pool; ! logger.info("Loading Docs"); String name = ""; //String reportPool; *************** *** 463,468 **** docsID.put(rs.getString(docid), repstr); } catch (Exception edoc) { ! log.println("DocName : " + name); ! edoc.printStackTrace(log); } } --- 465,469 ---- docsID.put(rs.getString(docid), repstr); } catch (Exception edoc) { ! logger.error("Could not load document " + docname,edoc); } } *************** *** 471,476 **** con.close(); } catch (Exception e99) { ! log.println("DocName : " + name); ! e99.printStackTrace(log); } } --- 472,476 ---- con.close(); } catch (Exception e99) { ! logger.error("Could not load document " + name,e99); } } *************** *** 480,484 **** */ public void retrieveDocDBs() throws Exception { ! log.println("Retrieving Doc Dbs"); Connection con; String dbPool; --- 480,484 ---- */ public void retrieveDocDBs() throws Exception { ! logger.info("Retrieving Doc Dbs"); Connection con; String dbPool; *************** *** 538,543 **** //tmpDB.returnConnection(con); } catch (Exception e) { ! e.printStackTrace(System.out); ! e.printStackTrace(log); } --- 538,542 ---- //tmpDB.returnConnection(con); } catch (Exception e) { ! logger.error("Could not load DBs",e); } *************** *** 549,570 **** protected void buildLog() throws Exception { ! formatter = new SimpleDateFormat("yyyy.MMMMM.dd hh::mm aaaa"); ! errorLog = ! new PrintStream(new FileOutputStream(new File(cfg.getErrorLog()))); ! String now = ! formatter.format(new java.util.Date(System.currentTimeMillis())); ! errorLog.println("[Log Begining " + now + "]"); } public void logEvent(String type, Exception mess) throws Exception { ! String now = ! formatter.format(new java.util.Date(System.currentTimeMillis())); ! errorLog.println("[Begin Event " + type + " " + now + "]"); ! mess.printStackTrace(errorLog); ! errorLog.println("[End Event " + type + " " + now + "]"); } public void close() throws Exception { ! errorLog.close(); } --- 548,561 ---- protected void buildLog() throws Exception { ! } public void logEvent(String type, Exception mess) throws Exception { ! logger.error(type,mess); ! } public void close() throws Exception { ! } Index: IdrsConfigHandler.java =================================================================== RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/core/servlet/IdrsConfigHandler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdrsConfigHandler.java 29 Aug 2004 05:01:38 -0000 1.3 --- IdrsConfigHandler.java 30 Aug 2004 00:56:07 -0000 1.4 *************** *** 57,60 **** --- 57,61 ---- public static final String var = "var"; public static final String securityImp = "securityImp"; + public static final String logLevel = "logLevel"; //public static final int scriptPoolMax = "scriptPoolMax".hashCode(); *************** *** 171,174 **** --- 172,177 ---- else if (localName.equalsIgnoreCase(this.securityImp)) { cfg.setSecurityImp(val); + } else if (localName.equalsIgnoreCase(this.logLevel)) { + cfg.setLogLevel(val); } Index: IdrsController.java =================================================================== RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/core/servlet/IdrsController.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** IdrsController.java 29 Aug 2004 05:01:38 -0000 1.7 --- IdrsController.java 30 Aug 2004 00:56:07 -0000 1.8 *************** *** 15,18 **** --- 15,20 ---- import javax.servlet.http.*; import javax.servlet.*; + + import org.apache.log4j.Logger; //import IDRSSecurity; //import IDRSReport; *************** *** 60,63 **** --- 62,66 ---- protected ServletContext servletContext; + static Logger logger = Logger.getLogger(IdrsController.class.getName()); /** * Constructor for IdrsController. *************** *** 154,159 **** req.setAttribute("fetchAddr", null); } catch (Exception e) { ! System.out.println(e + "\n" + e.getMessage() + "\n"); ! e.printStackTrace(); } } --- 157,161 ---- req.setAttribute("fetchAddr", null); } catch (Exception e) { ! logger.error("Could not return resources",e); } } *************** *** 311,315 **** for (int i = 0; i < Params.length; i++) { param = (String) Params[i]; ! System.out.println("Param : " + param); //determine what area of the header "db" is being added to db = param.substring(0, param.indexOf("_")); --- 313,317 ---- for (int i = 0; i < Params.length; i++) { param = (String) Params[i]; ! if (logger.isDebugEnabled()) logger.debug("Parameter : " + param); //determine what area of the header "db" is being added to db = param.substring(0, param.indexOf("_")); *************** *** 336,340 **** dbCache.remove(db); } ! ignore.printStackTrace(System.out); } } else if (param.indexOf("PageSize") != -1) { --- 338,342 ---- dbCache.remove(db); } ! logger.error("Could not reset document",ignore); } } else if (param.indexOf("PageSize") != -1) { *************** *** 450,457 **** try { isSecure = secure.checkOK(); ! System.out.println("Secure : " + isSecure); } catch (Exception securException) { //user is not authentic, deny access ! securException.printStackTrace(System.out); secure.close(); accessDenied(req, resp); --- 452,459 ---- try { isSecure = secure.checkOK(); ! if (logger.isDebugEnabled()) logger.debug("Secure : " + isSecure); } catch (Exception securException) { //user is not authentic, deny access ! logger.error("Error durring authentication",securException); secure.close(); accessDenied(req, resp); *************** *** 644,649 **** } catch (Exception e) { ! System.out.println("Error in parsing multi/part request"); ! e.printStackTrace(System.out); } --- 646,651 ---- } catch (Exception e) { ! logger.error("Error in parsing multi/part request",e); ! } |