public static void setProductName(String productName) { debugPattern = productName + " " + debugPattern; infoPattern = productName + " " + infoPattern; warnPattern = productName + " " + warnPattern; errorPattern = productName + " " + errorPattern; createLogger(debugPattern, logNameDebug, maxDebugSize, debugLog, Priority.DEBUG); createLogger(infoPattern, logNameInfo, maxInfoSize, infoLog, Priority.INFO); createLogger(warnPattern, logNameWarn, maxWarnSize, warnLog, Priority.WARN); createLogger(errorPattern, logNameError, maxErrorSize, errorLog, Priority.ERROR); }
/** * This method is used to initialize the Log class. For normal operations this method should * <b>never</b> be called, rather it's only publically available so that the class can be reset by * the setup process once the home directory has been specified. */ public static void initLog() { try { logDirectory = JiveGlobals.getXMLProperty("log.directory"); if (logDirectory == null) { if (JiveGlobals.getHomeDirectory() != null) { File wildfireHome = new File(JiveGlobals.getHomeDirectory()); if (wildfireHome.exists() && wildfireHome.canWrite()) { logDirectory = (new File(wildfireHome, "logs")).toString(); } } } if (!logDirectory.endsWith(File.separator)) { logDirectory = logDirectory + File.separator; } // Make sure the logs directory exists. If not, make it: File logDir = new File(logDirectory); if (!logDir.exists()) { logDir.mkdir(); } logNameDebug = logDirectory + "debug.log"; logNameInfo = logDirectory + "info.log"; logNameWarn = logDirectory + "warn.log"; logNameError = logDirectory + "error.log"; debugPattern = JiveGlobals.getXMLProperty("log.debug.format"); infoPattern = JiveGlobals.getXMLProperty("log.info.format"); warnPattern = JiveGlobals.getXMLProperty("log.warn.format"); errorPattern = JiveGlobals.getXMLProperty("log.error.format"); try { maxDebugSize = Long.parseLong(JiveGlobals.getXMLProperty("log.debug.size")); } catch (NumberFormatException e) { /* ignore */ } try { maxInfoSize = Long.parseLong(JiveGlobals.getXMLProperty("log.info.size")); } catch (NumberFormatException e) { /* ignore */ } try { maxWarnSize = Long.parseLong(JiveGlobals.getXMLProperty("log.warn.size")); } catch (NumberFormatException e) { /* ignore */ } try { maxErrorSize = Long.parseLong(JiveGlobals.getXMLProperty("log.error.size")); } catch (NumberFormatException e) { /* ignore */ } debugEnabled = "true".equals(JiveGlobals.getXMLProperty("log.debug.enabled")); } catch (Exception e) { // we'll get an exception if home isn't setup yet - we ignore that since // it's sure to be logged elsewhere :) } if (debugPattern == null) { debugPattern = "%{time:yyyy.MM.dd HH:mm:ss} %{message}\\n%{throwable}"; } if (infoPattern == null) { infoPattern = "%{time:yyyy.MM.dd HH:mm:ss} %{message}\\n%{throwable}"; } if (warnPattern == null) { warnPattern = "%{time:yyyy.MM.dd HH:mm:ss} %{message}\\n%{throwable}"; } if (errorPattern == null) { errorPattern = "%{time:yyyy.MM.dd HH:mm:ss} [%{method}] %{message}\\n%{throwable}"; } createLogger(debugPattern, logNameDebug, maxDebugSize, debugLog, Priority.DEBUG); createLogger(infoPattern, logNameInfo, maxInfoSize, infoLog, Priority.INFO); createLogger(warnPattern, logNameWarn, maxWarnSize, warnLog, Priority.WARN); createLogger(errorPattern, logNameError, maxErrorSize, errorLog, Priority.ERROR); // Running inside, JBoss it's really bad to redirect java.util.logging // // A) Because it's none of our business // B) Because it prevents us from cleanly being unloaded and loaded again // set up the ties into jdk logging // Handler jdkLogHandler = new JiveLogHandler(); // jdkLogHandler.setLevel(Level.ALL); // java.util.logging.Logger.getLogger("").addHandler(jdkLogHandler); }