/** * @deprecated Please use the {@link Level#toLevel(String)} method instead. */ public static Priority toPriority(String sArg) { return Level.toLevel(sArg); }
/** * @deprecated Please use the {@link Level#toLevel(String, Level)} method instead. */ public static Priority toPriority(String sArg, Priority defaultPriority) { return Level.toLevel(sArg, (Level) defaultPriority); } }
/** * @deprecated Please use the {@link Level#toLevel(int, Level)} method instead. */ public static Priority toPriority(int val, Priority defaultPriority) { return Level.toLevel(val, (Level) defaultPriority); }
/** Convert an integer passed as argument to a level. If the conversion fails, then this method returns {@link #DEBUG}. */ public static Level toLevel(int val) { return (Level) toLevel(val, Level.DEBUG); }
/** Convert the string passed as argument to a level. If the conversion fails, then this method returns {@link #DEBUG}. */ public static Level toLevel(String sArg) { return (Level) toLevel(sArg, Level.DEBUG); }
/** * @deprecated Please use the {@link Level#toLevel(String, Level)} method instead. */ public static Priority toPriority(String sArg, Priority defaultPriority) { return Level.toLevel(sArg, (Level) defaultPriority); } }
/** Convert the string passed as argument to a level. If the conversion fails, then this method returns {@link #DEBUG}. */ public static Level toLevel(String sArg) { return (Level) toLevel(sArg, Level.DEBUG); }
/** Convert an integer passed as argument to a level. If the conversion fails, then this method returns {@link #DEBUG}. */ public static Level toLevel(int val) { return (Level) toLevel(val, Level.DEBUG); }
/** * @deprecated Please use the {@link Level#toLevel(String)} method instead. */ public static Priority toPriority(String sArg) { return Level.toLevel(sArg); }
/** * @deprecated Please use the {@link Level#toLevel(int, Level)} method instead. */ public static Priority toPriority(int val, Priority defaultPriority) { return Level.toLevel(val, (Level) defaultPriority); }
/** * Resolved deserialized level to one of the stock instances. * May be overriden in classes derived from Level. * @return resolved object. * @throws ObjectStreamException if exception during resolution. */ private Object readResolve() throws ObjectStreamException { // // if the deserizalized object is exactly an instance of Level // if (getClass() == Level.class) { return toLevel(level); } // // extension of Level can't substitute stock item // return this; }
public static Level getLogLevel() { final String levelStr = System.getProperty(LOG_PROPERTY_KEY); return Level.toLevel(levelStr, Level.INFO); } }
/** @see DefaultHandler **/ public void startElement(String aNamespaceURI, String aLocalName, String aQName, Attributes aAtts) { mBuf.setLength(0); if (TAG_EVENT.equals(aQName)) { mThreadName = aAtts.getValue("thread"); mTimeStamp = Long.parseLong(aAtts.getValue("timestamp")); mCategoryName = aAtts.getValue("logger"); mLevel = Level.toLevel(aAtts.getValue("level")); } else if (TAG_LOCATION_INFO.equals(aQName)) { mLocationDetails = aAtts.getValue("class") + "." + aAtts.getValue("method") + "(" + aAtts.getValue("file") + ":" + aAtts.getValue("line") + ")"; } }
private void readLevel(ObjectInputStream ois) throws java.io.IOException, ClassNotFoundException { int p = ois.readInt(); try { String className = (String) ois.readObject(); if(className == null) { level = Level.toLevel(p); } else { Method m = (Method) methodCache.get(className); if(m == null) { Class clazz = Loader.loadClass(className); // Note that we use Class.getDeclaredMethod instead of // Class.getMethod. This assumes that the Level subclass // implements the toLevel(int) method which is a // requirement. Actually, it does not make sense for Level // subclasses NOT to implement this method. Also note that // only Level can be subclassed and not Priority. m = clazz.getDeclaredMethod(TO_LEVEL, TO_LEVEL_PARAMS); methodCache.put(className, m); } PARAM_ARRAY[0] = new Integer(p); level = (Level) m.invoke(null, PARAM_ARRAY); } } catch(Exception e) { LogLog.warn("Level deserialization failed, reverting to default.", e); level = Level.toLevel(p); } }
private static void process(org.apache.log4j.Logger log, String level, PrintWriter out) throws IOException { if (level != null) { if (!level.equals(org.apache.log4j.Level.toLevel(level).toString())) { out.println(MARKER + "<div class='text-danger'>" + "Bad level : <strong>" + level + "</strong><br />" + "</div>"); } else { log.setLevel(org.apache.log4j.Level.toLevel(level)); out.println(MARKER + "<div class='text-success'>" + "Setting Level to <strong>" + level + "</strong> ...<br />" + "</div>"); } } out.println(MARKER + "Effective level: <b>" + log.getEffectiveLevel() + "</b><br />"); }
/** The string form of {@link #setThreshold(Level)}. */ public void setThreshold(String levelStr) { Level l = (Level) Level.toLevel(levelStr, null); if(l != null) { setThreshold(l); } else { LogLog.warn("Could not convert ["+levelStr+"] to Level."); } }
private static void process(org.apache.log4j.Logger log, String level, PrintWriter out) throws IOException { if (level != null) { if (!level.equalsIgnoreCase(org.apache.log4j.Level.toLevel(level) .toString())) { out.println(MARKER + "Bad Level : <b>" + level + "</b><br />"); } else { log.setLevel(org.apache.log4j.Level.toLevel(level)); out.println(MARKER + "Setting Level to " + level + " ...<br />"); } } out.println(MARKER + "Effective Level: <b>" + log.getEffectiveLevel() + "</b><br />"); }
String className = (String) ois.readObject(); if(className == null) { level = Level.toLevel(p); } else { Method m = (Method) methodCache.get(className); level = Level.toLevel(p); } catch(NoSuchMethodException e) { LogLog.warn("Level deserialization failed, reverting to default.", e); level = Level.toLevel(p); } catch(IllegalAccessException e) { LogLog.warn("Level deserialization failed, reverting to default.", e); level = Level.toLevel(p); } catch(RuntimeException e) { LogLog.warn("Level deserialization failed, reverting to default.", e); level = Level.toLevel(p);
private LoggingEvent createEventWithException(final String message, final Exception e) { return new LoggingEvent(this.getClass().getCanonicalName(), this.logger, 0, Level.toLevel("INFO"), message, e); } }
private static void process(org.apache.log4j.Logger log, String level, LogInfo result) throws IOException { if (log == null) { result.setMessage("log is null."); return; } if (level != null) { if (!level.equals(org.apache.log4j.Level.toLevel(level).toString())) { result.setMessage("Bad level : " + level); } else { log.setLevel(org.apache.log4j.Level.toLevel(level)); result.setMessage("Setting Level to " + level); } } org.apache.log4j.Level lev = null; Category category = log; while ((category != null) && ((lev = category.getLevel()) == null)) { category = category.getParent(); } if (lev != null) { result.setLevel(lev.toString()); } }