Author: jaz
Date: Fri May 11 13:05:04 2007 New Revision: 537276 URL: http://svn.apache.org/viewvc?view=rev&rev=537276 Log: added new notify level to log4j - calls directly into the SMTPAppender to notify (email) specific log messages; use Debug.logNotify() to call into this; only use this for very NEED TO KNOW problems Added: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/NotifyLevel.java (with props) Modified: ofbiz/trunk/framework/base/config/log4j.xml ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java Modified: ofbiz/trunk/framework/base/config/log4j.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/config/log4j.xml?view=diff&rev=537276&r1=537275&r2=537276 ============================================================================== --- ofbiz/trunk/framework/base/config/log4j.xml (original) +++ ofbiz/trunk/framework/base/config/log4j.xml Fri May 11 13:05:04 2007 @@ -62,7 +62,9 @@ </appender> <!-- debug log --> - <appender name="debug" class="org.apache.log4j.FileAppender"> + <appender name="debug" class="org.apache.log4j.RollingFileAppender"> + <param name="maxFileSize" value="10000KB" /> + <param name="maxBackupIndex" value="10" /> <param name="File" value="runtime/logs/debug.log" /> <param name="Append" value="false"/> <layout class="org.apache.log4j.PatternLayout"> @@ -76,7 +78,9 @@ </appender> <!-- error log --> - <appender name="error" class="org.apache.log4j.FileAppender"> + <appender name="error" class="org.apache.log4j.RollingFileAppender"> + <param name="maxFileSize" value="10000KB" /> + <param name="maxBackupIndex" value="10" /> <param name="File" value="runtime/logs/error.log" /> <param name="Append" value="false"/> <layout class="org.apache.log4j.PatternLayout"> @@ -90,7 +94,9 @@ </appender> <!-- special minerva log --> - <appender name="minerva-log" class="org.apache.log4j.FileAppender"> + <appender name="minerva-log" class="org.apache.log4j.RollingFileAppender"> + <param name="maxFileSize" value="5000KB" /> + <param name="maxBackupIndex" value="10" /> <param name="File" value="runtime/logs/minerva.log" /> <param name="Append" value="false"/> <layout class="org.apache.log4j.PatternLayout"> @@ -105,18 +111,15 @@ <!-- fatal error SMTP notification --> <appender name="email" class="org.apache.log4j.net.SMTPAppender"> + <param name="threshold" value="fatal"/> <param name="BufferSize" value="512" /> <param name="SMTPHost" value="localhost" /> <param name="From" value="ofbiz-error@localhost" /> - <param name="To" value="[hidden email]" /> - <param name="Subject" value="[OFBiz-Error] Application message" /> + <param name="To" value="[hidden email]" /> <!-- at least change this field! --> + <param name="Subject" value="[OFBiz-Notify] Application message" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d (%t) [%24F:%-3L:%-5p]%x %m%n"/> </layout> - <filter class="org.apache.log4j.varia.LevelRangeFilter"> - <param name="LevelMin" value="fatal"/> - <param name="LevelMax" value="fatal"/> - </filter> </appender> <!-- log4j category --> @@ -126,7 +129,13 @@ <!-- log minerva to the special log --> <category name="org.ofbiz.minerva"> - <priority value="trace"/> + <priority value="warn"/> + <appender-ref ref="minerva-log"/> + </category> + + <!-- geronimo transaction logging --> + <category name="org.apache.geronimo.transaction"> + <priority value="warn"/> <appender-ref ref="minerva-log"/> </category> Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java?view=diff&rev=537276&r1=537275&r2=537276 ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/Debug.java Fri May 11 13:05:04 2007 @@ -30,13 +30,10 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; -import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.RollingFileAppender; import org.apache.log4j.Appender; import org.apache.log4j.spi.LoggerRepository; -import org.ofbiz.base.util.collections.FlexibleProperties; - /** * Configurable Debug logging wrapper class * @@ -57,37 +54,39 @@ public static final int WARNING = 5; public static final int ERROR = 6; public static final int FATAL = 7; + public static final int NOTIFY = 8; - public static final String[] levels = {"Always", "Verbose", "Timing", "Info", "Important", "Warning", "Error", "Fatal"}; - public static final String[] levelProps = {"", "print.verbose", "print.timing", "print.info", "print.important", "print.warning", "print.error", "print.fatal"}; - public static final Level[] levelObjs = {Level.INFO, Level.DEBUG, Level.DEBUG, Level.INFO, Level.INFO, Level.WARN, Level.ERROR, Level.FATAL}; + public static final String[] levels = {"Always", "Verbose", "Timing", "Info", "Important", "Warning", "Error", "Fatal", "Notify"}; + public static final String[] levelProps = {"", "print.verbose", "print.timing", "print.info", "print.important", "print.warning", "print.error", "print.fatal", "print.notify"}; + public static final Level[] levelObjs = {Level.INFO, Level.DEBUG, Level.DEBUG, Level.INFO, Level.INFO, Level.WARN, Level.ERROR, Level.FATAL, NotifyLevel.NOTIFY}; protected static Map levelStringMap = new HashMap(); protected static PrintStream printStream = System.out; protected static PrintWriter printWriter = new PrintWriter(printStream); - protected static boolean levelOnCache[] = new boolean[8]; + protected static boolean levelOnCache[] = new boolean[9]; protected static boolean packException = true; protected static final boolean useLevelOnCache = true; protected static Logger root = Logger.getRootLogger(); static { - levelStringMap.put("verbose", new Integer(Debug.VERBOSE)); - levelStringMap.put("timing", new Integer(Debug.TIMING)); - levelStringMap.put("info", new Integer(Debug.INFO)); - levelStringMap.put("important", new Integer(Debug.IMPORTANT)); - levelStringMap.put("warning", new Integer(Debug.WARNING)); - levelStringMap.put("error", new Integer(Debug.ERROR)); - levelStringMap.put("fatal", new Integer(Debug.FATAL)); - levelStringMap.put("always", new Integer(Debug.ALWAYS)); + levelStringMap.put("verbose", Debug.VERBOSE); + levelStringMap.put("timing", Debug.TIMING); + levelStringMap.put("info", Debug.INFO); + levelStringMap.put("important", Debug.IMPORTANT); + levelStringMap.put("warning", Debug.WARNING); + levelStringMap.put("error", Debug.ERROR); + levelStringMap.put("fatal", Debug.FATAL); + levelStringMap.put("always", Debug.ALWAYS); + levelStringMap.put("notify", Debug.NOTIFY); // initialize Log4J - PropertyConfigurator.configure(FlexibleProperties.makeFlexibleProperties(UtilURL.fromResource("debug.properties"))); + org.apache.log4j.xml.DOMConfigurator.configure(UtilURL.fromResource("log4j.xml")); // initialize levelOnCache - for (int i = 0; i < 8; i++) { + for (int i = 0; i < 9; i++) { levelOnCache[i] = (i == Debug.ALWAYS || UtilProperties.propertyValueEqualsIgnoreCase("debug.properties", levelProps[i], "true")); } @@ -140,7 +139,7 @@ if (levelInt == null) { return Debug.INFO; } else { - return levelInt.intValue(); + return levelInt; } } @@ -327,6 +326,18 @@ public static void logFatal(Throwable t, String msg, String module) { log(Debug.FATAL, t, msg, module); + } + + public static void logNotify(String msg, String module) { + log(Debug.NOTIFY, null, msg, module); + } + + public static void logNotify(Throwable t, String module) { + log(Debug.NOTIFY, t, null, module); + } + + public static void logNotify(Throwable t, String msg, String module) { + log(Debug.NOTIFY, t, msg, module); } public static void set(int level, boolean on) { Added: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/NotifyLevel.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/NotifyLevel.java?view=auto&rev=537276 ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/NotifyLevel.java (added) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/NotifyLevel.java Fri May 11 13:05:04 2007 @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2007 Andrew Zeneski. All Rights Reserved. + */ + +package org.ofbiz.base.util; + +import org.apache.log4j.Level; +import org.apache.log4j.net.SyslogAppender; + +/** + * NotifyLevel + */ +public class NotifyLevel extends Level { + + public static final int NOTIFY_INT = FATAL_INT + 10000; + public static final Level NOTIFY = new NotifyLevel(NOTIFY_INT, "NOTIFY", SyslogAppender.LOG_LOCAL0); + public static final Level notify = new NotifyLevel(NOTIFY_INT, "notify", SyslogAppender.LOG_LOCAL0); + + public NotifyLevel(int level, String levelStr, int syslogEquivalent) { + super(level, levelStr, syslogEquivalent); + } +} Propchange: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/NotifyLevel.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/NotifyLevel.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/NotifyLevel.java ------------------------------------------------------------------------------ svn:mime-type = text/plain |
Free forum by Nabble | Edit this page |