diff options
Diffstat (limited to 'log4j-over-slf4j/src')
26 files changed, 279 insertions, 174 deletions
diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/Appender.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/Appender.java index 3df673fb..fcc09994 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/Appender.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/Appender.java @@ -18,7 +18,6 @@ package org.apache.log4j; import org.apache.log4j.spi.Filter; import org.apache.log4j.spi.ErrorHandler; -import org.apache.log4j.spi.Layout; import org.apache.log4j.spi.LoggingEvent; /** @@ -55,7 +54,7 @@ public interface Appender { /** * Release any resources allocated within the appender such as file * handles, network connections, etc. - * <p/> + * * <p>It is a programming error to append to a closed appender. * * @since 0.8.4 @@ -115,12 +114,12 @@ public interface Appender { * Configurators call this method to determine if the appender * requires a layout. If this method returns <code>true</code>, * meaning that layout is required, then the configurator will - * configure an layout using the configuration information at its + * configure a layout using the configuration information at its * disposal. If this method returns <code>false</code>, meaning that * a layout is not required, then layout configuration will be * skipped even if there is available layout configuration - * information at the disposal of the configurator.. - * <p/> + * information at the disposal of the configurator. + * * <p>In the rather exceptional case, where the appender * implementation admits a layout but can also work without it, then * the appender should return <code>true</code>. diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java index 0d29fbe9..ee4d7893 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/Category.java @@ -29,7 +29,7 @@ import java.util.Enumeration; * This class is a minimal implementation of the original * <code>org.apache.log4j.Category</code> class (as found in log4j 1.2) by * delegation of all calls to a {@link org.slf4j.Logger} instance. - * </p> + * * * <p> * Log4j's <code>trace</code>, <code>debug()</code>, <code>info()</code>, @@ -45,12 +45,12 @@ public class Category { private static final String CATEGORY_FQCN = Category.class.getName(); - private String name; + private final String name; protected org.slf4j.Logger slf4jLogger; private org.slf4j.spi.LocationAwareLogger locationAwareLogger; - private static Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL"); + private static final Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL"); Category(String name) { this.name = name; @@ -125,6 +125,7 @@ public class Category { /** * @deprecated Please use {@link #getLevel} instead. + * @return a Level */ final public Level getPriority() { return null; @@ -132,6 +133,9 @@ public class Category { /** * Delegates to {@link org.slf4j.Logger#isDebugEnabled} method in SLF4J + * + * @return true if this logger is enabled for the level DEBUG + * */ public boolean isDebugEnabled() { return slf4jLogger.isDebugEnabled(); @@ -139,13 +143,17 @@ public class Category { /** * Delegates to {@link org.slf4j.Logger#isInfoEnabled} method in SLF4J + * + * @return true if this logger is enabled for the level INFO */ public boolean isInfoEnabled() { return slf4jLogger.isInfoEnabled(); } /** - * Delegates tob {@link org.slf4j.Logger#isWarnEnabled} method in SLF4J + * Delegates to {@link org.slf4j.Logger#isWarnEnabled} method in SLF4J + * + * @return true if this logger is enabled for the level WARN */ public boolean isWarnEnabled() { return slf4jLogger.isWarnEnabled(); @@ -153,6 +161,8 @@ public class Category { /** * Delegates to {@link org.slf4j.Logger#isErrorEnabled} method in SLF4J + * + * @return true if this logger is enabled for the level ERROR */ public boolean isErrorEnabled() { return slf4jLogger.isErrorEnabled(); @@ -160,13 +170,11 @@ public class Category { /** * Determines whether the priority passed as parameter is enabled in the - * underlying SLF4J logger. Each log4j priority is mapped directly to its - * SLF4J equivalent, except for FATAL which is mapped as ERROR. + * underlying SLF4J logger. Each log4j priority is mapped directly to its SLF4J + * equivalent, except for FATAL which is mapped as ERROR. * - * @param p - * the priority to check against - * @return true if this logger is enabled for the given level, false - * otherwise. + * @param p the priority to check against + * @return true if this logger is enabled for the given level, false otherwise. */ public boolean isEnabledFor(Priority p) { switch (p.level) { @@ -194,19 +202,19 @@ public class Category { } else { switch (level) { case LocationAwareLogger.TRACE_INT: - slf4jLogger.trace(marker, m); + slf4jLogger.trace(marker, m, (Throwable) t); break; case LocationAwareLogger.DEBUG_INT: - slf4jLogger.debug(marker, m); + slf4jLogger.debug(marker, m, (Throwable) t); break; case LocationAwareLogger.INFO_INT: - slf4jLogger.info(marker, m); + slf4jLogger.info(marker, m, (Throwable) t); break; case LocationAwareLogger.WARN_INT: - slf4jLogger.warn(marker, m); + slf4jLogger.warn(marker, m, (Throwable) t); break; case LocationAwareLogger.ERROR_INT: - slf4jLogger.error(marker, m); + slf4jLogger.error(marker, m, (Throwable) t); break; } } @@ -214,6 +222,8 @@ public class Category { /** * Delegates to {@link org.slf4j.Logger#debug(String)} method of SLF4J. + * + * @param message a message to log */ public void debug(Object message) { differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.DEBUG_INT, message, null); @@ -222,6 +232,9 @@ public class Category { /** * Delegates to {@link org.slf4j.Logger#debug(String,Throwable)} method in * SLF4J. + * + * @param message a message to log + * @param t a throwable to log */ public void debug(Object message, Throwable t) { differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.DEBUG_INT, message, t); @@ -229,14 +242,18 @@ public class Category { /** * Delegates to {@link org.slf4j.Logger#info(String)} method in SLF4J. + * + * @param message a message to log */ public void info(Object message) { differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.INFO_INT, message, null); } /** - * Delegates to {@link org.slf4j.Logger#info(String,Throwable)} method in - * SLF4J. + * Delegates to {@link org.slf4j.Logger#info(String,Throwable)} method in SLF4J. + * + * @param message a message to log + * @param t a throwable to log */ public void info(Object message, Throwable t) { differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.INFO_INT, message, t); @@ -244,14 +261,20 @@ public class Category { /** * Delegates to {@link org.slf4j.Logger#warn(String)} method in SLF4J. + * + * @param message a message to log + * */ public void warn(Object message) { differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.WARN_INT, message, null); } /** - * Delegates to {@link org.slf4j.Logger#warn(String,Throwable)} method in - * SLF4J. + * Delegates to {@link org.slf4j.Logger#warn(String,Throwable)} method in SLF4J. + * + * @param message a message to log + * @param t a throwable to log + * */ public void warn(Object message, Throwable t) { differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.WARN_INT, message, t); @@ -259,6 +282,9 @@ public class Category { /** * Delegates to {@link org.slf4j.Logger#error(String)} method in SLF4J. + * + * @param message a message to log + * */ public void error(Object message) { differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, null); @@ -267,6 +293,10 @@ public class Category { /** * Delegates to {@link org.slf4j.Logger#error(String,Throwable)} method in * SLF4J. + * + * @param message a message to log + * @param t a throwable to log + * */ public void error(Object message, Throwable t) { differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, t); @@ -274,6 +304,9 @@ public class Category { /** * Delegates to {@link org.slf4j.Logger#error(String)} method in SLF4J. + * + * @param message a message to log + * */ public void fatal(Object message) { differentiatedLog(FATAL_MARKER, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, null); @@ -282,6 +315,10 @@ public class Category { /** * Delegates to {@link org.slf4j.Logger#error(String,Throwable)} method in * SLF4J. In addition, the call is marked with a marker named "FATAL". + * + * @param message a message to log + * @param t a throwable to log + * */ public void fatal(Object message, Throwable t) { differentiatedLog(FATAL_MARKER, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT, message, t); @@ -291,7 +328,7 @@ public class Category { log(FQCN, p, msg, t); } - // See also http://bugzilla.slf4j.org/show_bug.cgi?id=168 + // See also http://jira.qos.ch/browse/SLF4J-159 public void log(String FQCN, Priority p, Object msg, Throwable t) { int levelInt = priorityToLevelInt(p); differentiatedLog(null, FQCN, levelInt, msg, t); @@ -347,4 +384,13 @@ public class Category { // nothing to do } + public boolean getAdditivity() { + return false; + } + + public void assertLog(boolean assertion, String msg) { + if (!assertion) + error(msg); + } + } diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/ConsoleAppender.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/ConsoleAppender.java index 40e8f800..c1935074 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/ConsoleAppender.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/ConsoleAppender.java @@ -15,6 +15,18 @@ */ package org.apache.log4j; +/** + * Skeleton implementation of ConsoleAppender + */ public class ConsoleAppender extends WriterAppender { + public ConsoleAppender() { + } + + public ConsoleAppender(Layout layout) { + } + + public ConsoleAppender(Layout layout, String target) { + } + } diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/Layout.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/Layout.java index 4ea3d990..1f4ef945 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/Layout.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/Layout.java @@ -20,7 +20,7 @@ package org.apache.log4j; /** * This class is a minimal implementation of the original Log4J class. * - * @author Christian Trutz <christian.trutz@belaso.de> + * @author Christian Trutz * */ public class Layout { diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/Level.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/Level.java index 62ef578e..ddadbea0 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/Level.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/Level.java @@ -26,21 +26,21 @@ import java.io.ObjectStreamException; import java.io.Serializable; /** - Defines the minimum set of levels recognized by the system, that is - <code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>, - <code>WARN</code>, <code>INFO</code>, <code>DEBUG</code> and - <code>ALL</code>. - - <p>The <code>Level</code> class may be subclassed to define a larger - level set. - - @author Ceki Gülcü - + * Defines the minimum set of levels recognized by the system, that is + * <code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>, <code>WARN</code>, + * <code>INFO</code>, <code>DEBUG</code> and <code>ALL</code>. + * + * <p> + * The <code>Level</code> class may be subclassed to define a larger level set. + * + * @author Ceki Gülcü + * */ public class Level extends Priority implements Serializable { /** * TRACE level integer value. + * * @since 1.2.12 */ public static final int TRACE_INT = 5000; @@ -49,48 +49,52 @@ public class Level extends Priority implements Serializable { public static final int X_TRACE_INT = DEBUG_INT - 100; /** - The <code>OFF</code> has the highest possible rank and is - intended to turn off logging. */ + * The <code>OFF</code> has the highest possible rank and is intended to turn + * off logging. + */ final static public Level OFF = new Level(OFF_INT, "OFF", 0); /** - The <code>FATAL</code> level designates very severe error - events that will presumably lead the application to abort. + * The <code>FATAL</code> level designates very severe error events that will + * presumably lead the application to abort. */ final static public Level FATAL = new Level(FATAL_INT, "FATAL", 0); /** - The <code>ERROR</code> level designates error events that - might still allow the application to continue running. */ + * The <code>ERROR</code> level designates error events that might still allow + * the application to continue running. + */ final static public Level ERROR = new Level(ERROR_INT, "ERROR", 3); /** - The <code>WARN</code> level designates potentially harmful situations. - */ + * The <code>WARN</code> level designates potentially harmful situations. + */ final static public Level WARN = new Level(WARN_INT, "WARN", 4); /** - The <code>INFO</code> level designates informational messages - that highlight the progress of the application at coarse-grained - level. */ + * The <code>INFO</code> level designates informational messages that highlight + * the progress of the application at coarse-grained level. + */ final static public Level INFO = new Level(INFO_INT, "INFO", 6); /** - The <code>DEBUG</code> Level designates fine-grained - informational events that are most useful to debug an - application. */ + * The <code>DEBUG</code> Level designates fine-grained informational events + * that are most useful to debug an application. + */ final static public Level DEBUG = new Level(DEBUG_INT, "DEBUG", 7); /** - * The <code>TRACE</code> Level designates finer-grained - * informational events than the <code>DEBUG</code level. - * @since 1.2.12 - */ + * The <code>TRACE</code> Level designates finer-grained informational events + * than the <code>DEBUG</code> level. + * + * @since 1.2.12 + */ public static final Level TRACE = new Level(TRACE_INT, "TRACE", 7); /** - The <code>ALL</code> has the lowest possible rank and is intended to - turn on all logging. */ + * The <code>ALL</code> has the lowest possible rank and is intended to turn on + * all logging. + */ final static public Level ALL = new Level(ALL_INT, "ALL", 7); /** @@ -99,33 +103,47 @@ public class Level extends Priority implements Serializable { static final long serialVersionUID = 3491141966387921974L; /** - Instantiate a Level object. + * Instantiate a Level object. + * + * @param level a level + * @param levelStr a level string + * @param syslogEquivalent the Syslog equivalent */ protected Level(int level, String levelStr, int syslogEquivalent) { super(level, levelStr, syslogEquivalent); } /** - Convert the string passed as argument to a level. If the - conversion fails, then this method returns {@link #DEBUG}. - */ + * Convert the string passed as argument to a level. If the conversion fails, + * then this method returns {@link #DEBUG}. + * + * @param sArg a string + * @return corresponding Level + * + */ 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}. - - */ + * Convert an integer passed as argument to a level. If the conversion fails, + * then this method returns {@link #DEBUG}. + * + * @param val an int + * @return a level + */ public static Level toLevel(int val) { return (Level) toLevel(val, Level.DEBUG); } /** - Convert an integer passed as argument to a level. If the - conversion fails, then this method returns the specified default. - */ + * Convert an integer passed as argument to a level. If the conversion fails, + * then this method returns the specified default. + * + * @param val a value + * @param defaultLevel a defaultLevel + * @return corresponding Level + */ public static Level toLevel(int val, Level defaultLevel) { switch (val) { case ALL_INT: @@ -150,10 +168,13 @@ public class Level extends Priority implements Serializable { } /** - Convert the string passed as argument to a level. If the - conversion fails, then this method returns the value of - <code>defaultLevel</code>. - */ + * Convert the string passed as argument to a level. If the conversion fails, + * then this method returns the value of <code>defaultLevel</code>. + * + * @param sArg a string + * @param defaultLevel a default level + * @return corresponding level + */ public static Level toLevel(String sArg, Level defaultLevel) { if (sArg == null) return defaultLevel; @@ -181,8 +202,9 @@ public class Level extends Priority implements Serializable { /** * Custom deserialization of Level. + * * @param s serialization stream. - * @throws IOException if IO exception. + * @throws IOException if IO exception. * @throws ClassNotFoundException if class not found. */ private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException { @@ -197,6 +219,7 @@ public class Level extends Priority implements Serializable { /** * Serialize level. + * * @param s serialization stream. * @throws IOException if exception during serialization. */ @@ -208,14 +231,15 @@ public class Level extends Priority implements Serializable { } /** - * Resolved deserialized level to one of the stock instances. - * May be overriden in classes derived from Level. + * Resolved deserialized level to one of the stock instances. May be overridden + * 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 the deserialized object is exactly an instance of Level // if (getClass() == Level.class) { return toLevel(level); diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java index 738b6a6c..eea3c97d 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/Log4jLoggerFactory.java @@ -17,7 +17,6 @@ package org.apache.log4j; import org.apache.log4j.spi.LoggerFactory; -import org.slf4j.helpers.Util; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -34,24 +33,7 @@ import java.util.concurrent.ConcurrentMap; class Log4jLoggerFactory { // String, Logger - private static ConcurrentMap<String, Logger> log4jLoggers = new ConcurrentHashMap<String, Logger>(); - - private static final String LOG4J_DELEGATION_LOOP_URL = "http://www.slf4j.org/codes.html#log4jDelegationLoop"; - - // check for delegation loops - static { - try { - Class.forName("org.slf4j.impl.Log4jLoggerFactory"); - String part1 = "Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError. "; - String part2 = "See also " + LOG4J_DELEGATION_LOOP_URL + " for more details."; - - Util.report(part1); - Util.report(part2); - throw new IllegalStateException(part1 + part2); - } catch (ClassNotFoundException e) { - // this is the good case - } - } + private static final ConcurrentMap<String, Logger> log4jLoggers = new ConcurrentHashMap<>(); public static Logger getLogger(String name) { org.apache.log4j.Logger instance = log4jLoggers.get(name); diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/LogManager.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/LogManager.java index 51c9c85d..42619190 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/LogManager.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/LogManager.java @@ -22,12 +22,11 @@ import java.util.Enumeration; import java.util.Vector; /** - * <p/> + * <p> * This class is a minimal implementation of the original * <code>org.apache.log4j.LogManager</code> class (as found in log4j 1.2) * delegating all calls to SLF4J. - * <p/> - * <p/> + * <p> * This implementation does <b>NOT</b> implement the setRepositorySelector(), * getLoggerRepository(), exists(), getCurrentLoggers(), shutdown() and * resetConfiguration() methods which do not have SLF4J equivalents. @@ -51,7 +50,7 @@ public class LogManager { /** * Returns a logger instance created by loggerFactory. This method was requested in - * <a href="http://bugzilla.slf4j.org/show_bug.cgi?id=234">bug #234</a>. Note that + * <a href="http://jira.qos.ch/browse/SLF4J-225">SLF4J-225</a>. Note that * log4j-over-slf4j does not ship with a LoggerFactory implementation. If this * method is called, the caller must provide his/her own implementation. * @@ -67,7 +66,7 @@ public class LogManager { /** * This bogus implementation returns an empty enumeration. * - * @return + * @return an Enumeration of current loggers */ public static Enumeration getCurrentLoggers() { return new Vector().elements(); diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java index 12ec1761..198b4e9e 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/Logger.java @@ -24,7 +24,7 @@ import org.slf4j.spi.LocationAwareLogger; * This class is a minimal implementation of the original * <code>org.apache.log4j.Logger</code> class (as found in log4j 1.2) * delegating all calls to a {@link org.slf4j.Logger} instance. - * </p> + * * * @author Ceki Gülcü * */ @@ -52,7 +52,7 @@ public class Logger extends Category { /** * Does the obvious. * - * @return + * @return the root logger */ public static Logger getRootLogger() { return Log4jLoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); @@ -61,6 +61,8 @@ public class Logger extends Category { /** * Delegates to {@link org.slf4j.Logger#isTraceEnabled} * method of SLF4J. + * + * @return whether this logger is enabled for the level TRACE */ public boolean isTraceEnabled() { return slf4jLogger.isTraceEnabled(); @@ -68,6 +70,9 @@ public class Logger extends Category { /** * Delegates to {@link org.slf4j.Logger#trace(String)} method in SLF4J. + * + * @param message the message to log + * */ public void trace(Object message) { differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null); @@ -76,9 +81,12 @@ public class Logger extends Category { /** * Delegates to {@link org.slf4j.Logger#trace(String,Throwable)} * method in SLF4J. + * + * @param message the message to log + * @param t a Throwable to log */ public void trace(Object message, Throwable t) { - differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null); + differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, t); } } diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/MDC.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/MDC.java index c4a8eff4..32118d4d 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/MDC.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/MDC.java @@ -49,6 +49,8 @@ public class MDC { * This method is not part of the Log4J public API. However it * has been called by other projects. This method is here temporarily * until projects who are depending on this method release fixes. + * + * @return a copy of the underlying map returned as a Hashtable */ @SuppressWarnings({ "rawtypes", "unchecked" }) @Deprecated diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/PatternLayout.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/PatternLayout.java index a38df63b..a65fa2b9 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/PatternLayout.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/PatternLayout.java @@ -20,7 +20,7 @@ package org.apache.log4j; /** * This class is a minimal implementation of the original Log4J class. * - * @author Christian Trutz <christian.trutz@belaso.de> + * @author Christian Trutz * */ public class PatternLayout extends Layout { diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/Priority.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/Priority.java index bb4f8d4a..08eebca9 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/Priority.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/Priority.java @@ -21,8 +21,8 @@ package org.apache.log4j; // Contributors: Kitching Simon <Simon.Kitching@OOOrange.ch> /** - <font color="#AA4444">Refrain from using this class directly, use - the {@link Level} class instead</font>. + <b>Refrain from using this class directly, use + the {@link Level} class instead</b>. @author Ceki Gülcü */ public class Priority { @@ -48,21 +48,25 @@ public class Priority { /** * @deprecated Use {@link Level#ERROR} instead. */ + @Deprecated final static public Priority ERROR = new Level(ERROR_INT, "ERROR", 3); /** * @deprecated Use {@link Level#WARN} instead. */ + @Deprecated final static public Priority WARN = new Level(WARN_INT, "WARN", 4); /** * @deprecated Use {@link Level#INFO} instead. */ + @Deprecated final static public Priority INFO = new Level(INFO_INT, "INFO", 6); /** * @deprecated Use {@link Level#DEBUG} instead. */ + @Deprecated final static public Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7); /** @@ -76,6 +80,15 @@ public class Priority { /** Instantiate a level object. + @param + */ + + /** + * Instantiate a level object. + * + * @param level a level as in int + * @param levelStr a levelStr + * @param syslogEquivalent the syslog equivalent level integer */ protected Priority(int level, String levelStr, int syslogEquivalent) { this.level = level; @@ -98,20 +111,23 @@ public class Priority { /** Return the syslog equivalent of this priority as an integer. + @return the Syslog Equivalent of this Priority */ public final int getSyslogEquivalent() { return syslogEquivalent; } /** - Returns <code>true</code> if this level has a higher or equal - level than the level passed as argument, <code>false</code> - otherwise. - - <p>You should think twice before overriding the default - implementation of <code>isGreaterOrEqual</code> method. - - */ + * Returns <code>true</code> if this level has a higher or equal + * level than the level passed as argument, <code>false</code> + * otherwise. + * + * <p>You should think twice before overriding the default + * implementation of <code>isGreaterOrEqual</code> method. + * + * @param r a priority + * @return a boolean + */ public boolean isGreaterOrEqual(Priority r) { return level >= r.level; } @@ -119,9 +135,11 @@ public class Priority { /** Return all possible priorities as an array of Level objects in descending order. - + @deprecated This method will be removed with no replacement. + @return array of all possible priorities */ + @Deprecated public static Priority[] getAllPossiblePriorities() { return new Priority[] { Priority.FATAL, Priority.ERROR, Level.WARN, Priority.INFO, Priority.DEBUG }; } @@ -134,7 +152,9 @@ public class Priority { } /** - Returns the integer representation of this level. + * Returns the integer representation of this level. + * + * @return integer representation of this level */ public final int toInt() { return level; @@ -142,29 +162,46 @@ public class Priority { /** * @deprecated Please use the {@link Level#toLevel(String)} method instead. + * + * @param sArg a string to convert to a Priority + * @return the corresponding Priority */ + @Deprecated public static Priority toPriority(String sArg) { return Level.toLevel(sArg); } /** * @deprecated Please use the {@link Level#toLevel(int)} method instead. + * + * @param val an integer to convert to a Priority + * @return the corresponding Priority */ + @Deprecated public static Priority toPriority(int val) { return toPriority(val, Priority.DEBUG); } /** * @deprecated Please use the {@link Level#toLevel(int, Level)} method instead. - */ + * + * @param val an integer value + * @param defaultPriority a default priority value + * @return corresponding Priority value + */ + @Deprecated public static Priority toPriority(int val, Priority defaultPriority) { return Level.toLevel(val, (Level) defaultPriority); } /** * @deprecated Please use the {@link Level#toLevel(String, Level)} method instead. + * @param sArg string value + * @param defaultPriority a default Priority + * @return a Priority */ + @Deprecated public static Priority toPriority(String sArg, Priority defaultPriority) { return Level.toLevel(sArg, (Level) defaultPriority); } -}
\ No newline at end of file +} diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/PropertyConfigurator.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/PropertyConfigurator.java index baf4c136..6af30d06 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/PropertyConfigurator.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/PropertyConfigurator.java @@ -23,7 +23,7 @@ import org.apache.log4j.spi.Configurator; import org.apache.log4j.spi.LoggerRepository; /** - * An nop implementation of PropertyConfigurator. + * A no-op implementation of PropertyConfigurator. */ public class PropertyConfigurator implements Configurator { public static void configure(Properties properties) { diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/RollingFileAppender.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/RollingFileAppender.java index b3295974..7cecc550 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/RollingFileAppender.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/RollingFileAppender.java @@ -22,7 +22,7 @@ import java.io.IOException; /** * This class is a minimal implementation of the original Log4J class. * - * @author Christian Trutz <christian.trutz@belaso.de> + * @author Christian Trutz * */ public class RollingFileAppender { diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/helpers/LogLog.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/helpers/LogLog.java index 01157ab7..0270e418 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/helpers/LogLog.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/helpers/LogLog.java @@ -25,7 +25,7 @@ package org.apache.log4j.helpers; <b>log4j.configDebug</b> variable. <p>All log4j internal debug calls go to <code>System.out</code> - where as internal error messages are sent to + whereas internal error messages are sent to <code>System.err</code>. All internal messages are prepended with the string "log4j: ". @@ -37,20 +37,20 @@ public class LogLog { /** Defining this value makes log4j print log4j-internal debug statements to <code>System.out</code>. - + <p> The value of this string is <b>log4j.debug</b>. - - <p>Note that the search for all option names is case sensitive. */ + + <p>Note that the search for all option names is case-sensitive. */ public static final String DEBUG_KEY = "log4j.debug"; /** Defining this value makes log4j components print log4j-internal debug statements to <code>System.out</code>. - + <p> The value of this string is <b>log4j.configDebug</b>. - - <p>Note that the search for all option names is case sensitive. - + + <p>Note that the search for all option names is case-sensitive. + @deprecated Use {@link #DEBUG_KEY} instead. */ public static final String CONFIG_DEBUG_KEY = "log4j.configDebug"; @@ -127,7 +127,7 @@ public class LogLog { /** In quite mode no LogLog generates strictly no output, not even for errors. - + @param quietMode A true for not */ public static void setQuietMode(boolean quietMode) { diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/Configurator.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/Configurator.java index abf75609..f15cbf07 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/Configurator.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/Configurator.java @@ -16,7 +16,6 @@ package org.apache.log4j.spi; -import org.apache.log4j.spi.LoggerRepository; import java.net.URL; /** @@ -41,10 +40,10 @@ public interface Configurator { /** Interpret a resource pointed by a URL and set up log4j accordingly. - + The configuration is done relative to the <code>hierarchy</code> parameter. - + @param url The URL to parse @param repository The hierarchy to operation upon. */ diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java index a774949e..9271b70b 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java @@ -19,7 +19,7 @@ package org.apache.log4j.spi; import org.apache.log4j.*; /** - Listen to events occuring within a {@link + Listen to events occurring within a {@link org.apache.log4j.Hierarchy Hierarchy}. @author Ceki Gülcü diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/Layout.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/Layout.java deleted file mode 100644 index 32d49074..00000000 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/Layout.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.log4j.spi; - -public class Layout { -} diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/LoggerFactory.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/LoggerFactory.java index c3e756d7..0f008bfa 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/LoggerFactory.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/LoggerFactory.java @@ -21,7 +21,7 @@ import org.apache.log4j.Logger; /** Implement this interface to create new instances of Logger or - a sub-class of Logger. + a subclass of Logger. <p>See <code>examples/subclass/MyLogger.java</code> for an example. diff --git a/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/LoggerRepository.java b/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/LoggerRepository.java index 4decdb78..87a3b61d 100644 --- a/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/LoggerRepository.java +++ b/log4j-over-slf4j/src/main/java/org/apache/log4j/spi/LoggerRepository.java @@ -25,7 +25,7 @@ import java.util.Enumeration; * <code>Loggers</code>. The relation between loggers in a repository * depends on the repository but typically loggers are arranged in a * named hierarchy. - * <p/> + * * <p>In addition to the creational methods, a * <code>LoggerRepository</code> can be queried for existing loggers, * can act as a point of registry for events related to loggers. @@ -37,6 +37,8 @@ public interface LoggerRepository { /** * Add a {@link HierarchyEventListener} event to the repository. + * + * @param listener a listener */ public void addHierarchyEventListener(HierarchyEventListener listener); diff --git a/log4j-over-slf4j/src/main/java9/module-info.java b/log4j-over-slf4j/src/main/java9/module-info.java new file mode 100755 index 00000000..35017bea --- /dev/null +++ b/log4j-over-slf4j/src/main/java9/module-info.java @@ -0,0 +1,8 @@ +module log4j { + requires org.slf4j; + requires java.xml; + exports org.apache.log4j; + exports org.apache.log4j.helpers; + exports org.apache.log4j.spi; + exports org.apache.log4j.xml; +}
\ No newline at end of file diff --git a/log4j-over-slf4j/src/main/resources/META-INF/MANIFEST.MF b/log4j-over-slf4j/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 531f5842..00000000 --- a/log4j-over-slf4j/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,8 +0,0 @@ -Implementation-Title: log4j-over-slf4j -Bundle-ManifestVersion: 2 -Bundle-SymbolicName: log4j.over.slf4j -Bundle-Name: log4j-over-slf4j -Bundle-Vendor: SLF4J.ORG -Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Export-Package: org.apache.log4j;version=${log4j.version},org.apache.log4j.helpers;version=${log4j.version},org.apache.log4j.spi;version=${log4j.version},org.apache.log4j.xml;version=${log4j.version} -Import-Package: org.slf4j;version=${slf4j.api.minimum.compatible.version}, org.slf4j.helpers;version=${slf4j.api.minimum.compatible.version}, org.slf4j.spi;version=${slf4j.api.minimum.compatible.version} diff --git a/log4j-over-slf4j/src/test/java/org/apache/log4j/NDCTest.java b/log4j-over-slf4j/src/test/java/org/apache/log4j/test/NDCTest.java index 74c2cd3b..ff87cff4 100644 --- a/log4j-over-slf4j/src/test/java/org/apache/log4j/NDCTest.java +++ b/log4j-over-slf4j/src/test/java/org/apache/log4j/test/NDCTest.java @@ -22,35 +22,46 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ -package org.apache.log4j; +package org.apache.log4j.test; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import org.apache.log4j.NDC; /** - * @author Ceki Gücü + * @author Ceki Gülcü */ -public class NDCTest extends TestCase { +public class NDCTest { + @Before public void setUp() { assertEquals(0, NDC.getDepth()); } + @After public void tearDown() { NDC.clear(); } + @Test public void testSmoke() { NDC.push("a"); String back = NDC.pop(); assertEquals("a", back); } + @Test public void testPop() { NDC.push("peek"); String back = NDC.peek(); assertEquals("peek", back); } + @Test public void testClear() { NDC.push("clear"); NDC.clear(); diff --git a/log4j-over-slf4j/src/test/java/org/apache/log4j/Trivial.java b/log4j-over-slf4j/src/test/java/org/apache/log4j/test/Trivial.java index 50edf2d3..6a8fbcc5 100644 --- a/log4j-over-slf4j/src/test/java/org/apache/log4j/Trivial.java +++ b/log4j-over-slf4j/src/test/java/org/apache/log4j/test/Trivial.java @@ -22,7 +22,7 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ -package org.apache.log4j; +package org.apache.log4j.test; import org.apache.log4j.Logger; diff --git a/log4j-over-slf4j/src/test/java/org/dummy/Bug131.java b/log4j-over-slf4j/src/test/java/org/dummy/Bug131.java index c97d5666..4453ac22 100644 --- a/log4j-over-slf4j/src/test/java/org/dummy/Bug131.java +++ b/log4j-over-slf4j/src/test/java/org/dummy/Bug131.java @@ -24,16 +24,18 @@ */ package org.dummy; +import static org.junit.Assert.assertEquals; + import java.util.logging.Level; import java.util.logging.LogRecord; -import junit.framework.TestCase; - import org.apache.log4j.Category; import org.apache.log4j.Logger; +import org.junit.Test; -public class Bug131 extends TestCase { +public class Bug131 { + @Test public void testBug131() { ListHandler listHandler = new ListHandler(); diff --git a/log4j-over-slf4j/src/test/java/org/dummy/Bug139.java b/log4j-over-slf4j/src/test/java/org/dummy/Bug139.java index f6cfe63f..1bb280ce 100644 --- a/log4j-over-slf4j/src/test/java/org/dummy/Bug139.java +++ b/log4j-over-slf4j/src/test/java/org/dummy/Bug139.java @@ -24,16 +24,18 @@ */ package org.dummy; +import static org.junit.Assert.assertEquals; + import java.util.logging.Level; import java.util.logging.LogRecord; -import junit.framework.TestCase; - import org.apache.log4j.Category; import org.apache.log4j.Logger; +import org.junit.Test; -public class Bug139 extends TestCase { +public class Bug139 { + @Test public void test() { ListHandler listHandler = new ListHandler(); java.util.logging.Logger root = java.util.logging.Logger.getLogger(""); diff --git a/log4j-over-slf4j/src/test/java/org/dummy/ListHandler.java b/log4j-over-slf4j/src/test/java/org/dummy/ListHandler.java index c29ebfa1..2a237239 100644 --- a/log4j-over-slf4j/src/test/java/org/dummy/ListHandler.java +++ b/log4j-over-slf4j/src/test/java/org/dummy/ListHandler.java @@ -31,7 +31,7 @@ import java.util.logging.LogRecord; public class ListHandler extends Handler { - List<LogRecord> list = new ArrayList<LogRecord>(); + List<LogRecord> list = new ArrayList<>(); public void close() throws SecurityException { |