Author: ceki
Date: Tue Dec 27 11:30:26 2005
New Revision: 472
Modified:
nlog4j/trunk/src/java/org/apache/log4j/Category.java
Log:
sync with SLF4J 1.0RC4 (arrray arggs in Logger)
Modified: nlog4j/trunk/src/java/org/apache/log4j/Category.java
==============================================================================
--- nlog4j/trunk/src/java/org/apache/log4j/Category.java (original)
+++ nlog4j/trunk/src/java/org/apache/log4j/Category.java Tue Dec 27
11:30:26 2005
@@ -18,7 +18,6 @@
// Aaron Greenhouse <[EMAIL PROTECTED]>
// Beat Meier <[EMAIL PROTECTED]>
// Colin Sampaleanu <[EMAIL PROTECTED]>
-
package org.apache.log4j;
import org.apache.log4j.spi.AppenderAttachable;
@@ -34,76 +33,80 @@
import org.slf4j.impl.MessageFormatter;
/**
- * <font color="#AA2222"><b>This class has been deprecated and
- * replaced by the [EMAIL PROTECTED] Logger} <em>subclass</em></b></font>. It
- * will be kept around to preserve backward compatibility until mid
- * 2003.
- *
- * <p><code>Logger</code> is a subclass of Category, i.e. it extends
- * Category. In other words, a logger <em>is</em> a category. Thus,
- * all operations that can be performed on a category can be
- * performed on a logger. Internally, whenever log4j is asked to
- * produce a Category object, it will instead produce a Logger
- * object. Log4j 1.2 will <em>never</em> produce Category objects but
- * only <code>Logger</code> instances. In order to preserve backward
- * compatibility, methods that previously accepted category objects
- * still continue to accept category objects.
- *
- * <p>For example, the following are all legal and will work as
- * expected.
- *
- <pre>
- // Deprecated form:
- Category cat = Category.getInstance("foo.bar")
-
- // Preferred form for retrieving loggers:
- Logger logger = Logger.getLogger("foo.bar")
- </pre>
-
- * <p>The first form is deprecated and should be avoided.
- *
- * <p><b>There is absolutely no need for new client code to use or
- * refer to the <code>Category</code> class.</b> Whenever possible,
- * please avoid referring to it or using it.
- *
- * <p>See the <a href="../../../../manual.html">short manual</a> for an
- * introduction on this class.
- * <p>
- * See the document entitled <a
href="http://www.qos.ch/logging/preparingFor13.html">preparing
- * for log4j 1.3</a> for a more detailed discussion.
- *
- * @author Ceki Gülcü
- * @author Anders Kristensen
- */
+ * <font color="#AA2222"><b>This class has been deprecated and replaced by the
+ * [EMAIL PROTECTED] Logger} <em>subclass</em></b></font>. It will be kept
around to
+ * preserve backward compatibility until mid 2003.
+ *
+ * <p>
+ * <code>Logger</code> is a subclass of Category, i.e. it extends Category. In
+ * other words, a logger <em>is</em> a category. Thus, all operations that can
+ * be performed on a category can be performed on a logger. Internally,
whenever
+ * log4j is asked to produce a Category object, it will instead produce a
Logger
+ * object. Log4j 1.2 will <em>never</em> produce Category objects but only
+ * <code>Logger</code> instances. In order to preserve backward compatibility,
+ * methods that previously accepted category objects still continue to accept
+ * category objects.
+ *
+ * <p>
+ * For example, the following are all legal and will work as expected.
+ *
+ * <pre>
+ * // Deprecated form:
+ * Category cat = Category.getInstance("foo.bar")
+ *
+ * // Preferred form for retrieving loggers:
+ * Logger logger = Logger.getLogger("foo.bar")
+ * </pre>
+ *
+ * <p>
+ * The first form is deprecated and should be avoided.
+ *
+ * <p>
+ * <b>There is absolutely no need for new client code to use or refer to the
+ * <code>Category</code> class.</b> Whenever possible, please avoid referring
+ * to it or using it.
+ *
+ * <p>
+ * See the <a href="../../../../manual.html">short manual</a> for an
+ * introduction on this class.
+ * <p>
+ * See the document entitled <a
+ * href="http://www.qos.ch/logging/preparingFor13.html">preparing for log4j
1.3</a>
+ * for a more detailed discussion.
+ *
+ * @author Ceki Gülcü
+ * @author Anders Kristensen
+ */
public class Category implements AppenderAttachable {
/**
- The hierarchy where categories are attached to by default.
- */
- //static
- //public
- //final Hierarchy defaultHierarchy = new Hierarchy(new
- // RootCategory(Level.DEBUG));
-
- /**
- The name of this category.
- */
- protected String name;
-
- /**
- The assigned level of this category. The
- <code>level</code> variable need not be assigned a value in
- which case it is inherited form the hierarchy. */
+ * The hierarchy where categories are attached to by default.
+ */
+ // static
+ // public
+ // final Hierarchy defaultHierarchy = new Hierarchy(new
+ // RootCategory(Level.DEBUG));
+ /**
+ * The name of this category.
+ */
+ protected String name;
+
+ /**
+ * The assigned level of this category. The <code>level</code> variable need
+ * not be assigned a value in which case it is inherited form the hierarchy.
+ */
volatile protected Level level;
/**
- The parent of this category. All categories have at least one
- ancestor which is the root category. */
+ * The parent of this category. All categories have at least one ancestor
+ * which is the root category.
+ */
volatile protected Category parent;
/**
- The fully qualified name of the Category class. See also the
- getFQCN method. */
+ * The fully qualified name of the Category class. See also the getFQCN
+ * method.
+ */
private static final String FQCN = Category.class.getName();
protected ResourceBundle resourceBundle;
@@ -111,43 +114,43 @@
// Categories need to know what Hierarchy they are in
protected LoggerRepository repository;
-
AppenderAttachableImpl aai;
- /** Additivity is set to true by default, that is children inherit
- the appenders of their ancestors by default. If this variable is
- set to <code>false</code> then the appenders found in the
- ancestors of this category are not used. However, the children
- of this category will inherit its appenders, unless the children
- have their additivity flag set to <code>false</code> too. See
- the user manual for more details. */
+ /**
+ * Additivity is set to true by default, that is children inherit the
+ * appenders of their ancestors by default. If this variable is set to
+ * <code>false</code> then the appenders found in the ancestors of this
+ * category are not used. However, the children of this category will inherit
+ * its appenders, unless the children have their additivity flag set to
+ * <code>false</code> too. See the user manual for more details.
+ */
protected boolean additive = true;
/**
- This constructor created a new <code>Category</code> instance and
- sets its name.
-
- <p>It is intended to be used by sub-classes only. You should not
- create categories directly.
-
- @param name The name of the category.
- */
- protected
- Category(String name) {
+ * This constructor created a new <code>Category</code> instance and sets
+ * its name.
+ *
+ * <p>
+ * It is intended to be used by sub-classes only. You should not create
+ * categories directly.
+ *
+ * @param name
+ * The name of the category.
+ */
+ protected Category(String name) {
this.name = name;
}
/**
- Add <code>newAppender</code> to the list of appenders of this
- Category instance.
-
- <p>If <code>newAppender</code> is already in the list of
- appenders, then it won't be added again.
- */
- synchronized
- public
- void addAppender(Appender newAppender) {
- if(aai == null) {
+ * Add <code>newAppender</code> to the list of appenders of this Category
+ * instance.
+ *
+ * <p>
+ * If <code>newAppender</code> is already in the list of appenders, then it
+ * won't be added again.
+ */
+ synchronized public void addAppender(Appender newAppender) {
+ if (aai == null) {
aai = new AppenderAttachableImpl();
}
aai.addAppender(newAppender);
@@ -155,65 +158,67 @@
}
/**
- If <code>assertion</code> parameter is <code>false</code>, then
- logs <code>msg</code> as an [EMAIL PROTECTED] #error(String) error}
statement.
-
- <p>The <code>assert</code> method has been renamed to
- <code>assertLog</code> because <code>assert</code> is a language
- reserved word in JDK 1.4.
-
- @param assertion
- @param msg The message to print if <code>assertion</code> is
- false.
-
- @since 1.2 */
+ * If <code>assertion</code> parameter is <code>false</code>, then logs
+ * <code>msg</code> as an [EMAIL PROTECTED] #error(String) error} statement.
+ *
+ * <p>
+ * The <code>assert</code> method has been renamed to <code>assertLog</code>
+ * because <code>assert</code> is a language reserved word in JDK 1.4.
+ *
+ * @param assertion
+ * @param msg
+ * The message to print if <code>assertion</code> is false.
+ *
+ * @since 1.2
+ */
public void assertLog(boolean assertion, String msg) {
- if(!assertion)
+ if (!assertion)
this.error(msg);
}
-
/**
- Call the appenders in the hierrachy starting at
- <code>this</code>. If no appenders could be found, emit a
- warning.
-
- <p>This method calls all the appenders inherited from the
- hierarchy circumventing any evaluation of whether to log or not
- to log the particular log request.
-
- @param event the event to log. */
+ * Call the appenders in the hierrachy starting at <code>this</code>. If no
+ * appenders could be found, emit a warning.
+ *
+ * <p>
+ * This method calls all the appenders inherited from the hierarchy
+ * circumventing any evaluation of whether to log or not to log the
particular
+ * log request.
+ *
+ * @param event
+ * the event to log.
+ */
public void callAppenders(LoggingEvent event) {
int writes = 0;
- for(Category c = this; c != null; c=c.parent) {
+ for (Category c = this; c != null; c = c.parent) {
// Protected against simultaneous call to addAppender, removeAppender,...
- synchronized(c) {
- if(c.aai != null) {
- writes += c.aai.appendLoopOnAppenders(event);
- }
- if(!c.additive) {
- break;
- }
+ synchronized (c) {
+ if (c.aai != null) {
+ writes += c.aai.appendLoopOnAppenders(event);
+ }
+ if (!c.additive) {
+ break;
+ }
}
}
- if(writes == 0) {
+ if (writes == 0) {
repository.emitNoAppenderWarning(this);
}
}
/**
- Close all attached appenders implementing the AppenderAttachable
- interface.
- @since 1.0
- */
+ * Close all attached appenders implementing the AppenderAttachable
interface.
+ *
+ * @since 1.0
+ */
synchronized void closeNestedAppenders() {
Enumeration enumeration = this.getAllAppenders();
- if(enumeration != null) {
- while(enumeration.hasMoreElements()) {
+ if (enumeration != null) {
+ while (enumeration.hasMoreElements()) {
Appender a = (Appender) enumeration.nextElement();
- if(a instanceof AppenderAttachable) {
+ if (a instanceof AppenderAttachable) {
a.close();
}
}
@@ -222,13 +227,14 @@
/**
* Log a message string at the DEBUG level.
- *
- * @param message the message string to log.
+ *
+ * @param message
+ * the message string to log.
*/
public void debug(String message) {
- if(repository.isDisabled(Level.DEBUG_INT))
+ if (repository.isDisabled(Level.DEBUG_INT))
return;
- if(Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel())) {
+ if (Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel())) {
forcedLog(FQCN, Level.DEBUG, message, null);
}
}
@@ -241,20 +247,23 @@
}
/**
- * Log a message at the <code>DEBUG</code> level with message
- * formatting done according to the value of
- * <code>format</code> and the <code>arg</code> parameters.
- *
- * <p>This form avoids superflous parameter construction.
+ * Log a message at the <code>DEBUG</code> level with message formatting
+ * done according to the value of <code>format</code> and the
+ * <code>arg</code> parameters.
+ *
+ * <p>
+ * This form avoids superflous parameter construction.
*
- * @param format the format
- * @param arg the argument for substitution
+ * @param format
+ * the format
+ * @param arg
+ * the argument for substitution
*/
public void debug(String format, Object arg) {
if (repository.isDisabled(Level.DEBUG_INT)) {
return;
}
-
+
if (Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel())) {
String msgStr = MessageFormatter.format(format, arg);
forcedLog(FQCN, Level.DEBUG, msgStr, null);
@@ -262,14 +271,18 @@
}
/**
- * Log a message at the DEBUG level according to the specified
- * format and arguments.
- *
- * <p> This form avoids superflous object creations.
- *
- * @param format the format
- * @param arg1 the first argument
- * @param arg2 the second argument
+ * Log a message at the DEBUG level according to the specified format and
+ * arguments.
+ *
+ * <p>
+ * This form avoids superflous object creations.
+ *
+ * @param format
+ * the format
+ * @param arg1
+ * the first argument
+ * @param arg2
+ * the second argument
*/
public void debug(String format, Object arg1, Object arg2) {
if (repository.isDisabled(Level.DEBUG_INT)) {
@@ -281,43 +294,67 @@
}
}
+ /**
+ * Log a message at the DEBUG level according to the specified format and
+ * arguments.
+ *
+ * <p>
+ * This form avoids superflous object creations.
+ *
+ * @param format
+ * the format
+ * @param argArray
+ * an array of arguments
+ */
+ public void debug(String format, Object argArray[]) {
+ if (repository.isDisabled(Level.DEBUG_INT)) {
+ return;
+ }
+
+ if (Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel())) {
+ String msgStr = MessageFormatter.arrayFormat(format, argArray);
+ forcedLog(FQCN, Level.DEBUG, msgStr, null);
+ }
+ }
-
/**
- * Log an exception (throwable) at the DEBUG level with an
- * accompanying message.
- *
- * @param message the message accompanying the exception
- * @param t the exception (throwable) to log, including its stack
- * trace.
+ * Log an exception (throwable) at the DEBUG level with an accompanying
+ * message.
+ *
+ * @param message
+ * the message accompanying the exception
+ * @param t
+ * the exception (throwable) to log, including its stack trace.
*/
public void debug(String message, Throwable t) {
- if(repository.isDisabled(Level.DEBUG_INT))
+ if (repository.isDisabled(Level.DEBUG_INT))
return;
- if(Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel()))
+ if (Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel()))
forcedLog(FQCN, Level.DEBUG, message, t);
}
/**
* Log a message string at the [EMAIL PROTECTED] Level#ERROR ERROR} Level.
- *
- * <p>This method first checks if this category is
- * <code>ERROR</code> enabled by comparing the level of this
- * category with [EMAIL PROTECTED] Level#ERROR ERROR} Level.
- *
- * @param message the message object to log
+ *
+ * <p>
+ * This method first checks if this category is <code>ERROR</code> enabled
+ * by comparing the level of this category with [EMAIL PROTECTED]
Level#ERROR ERROR}
+ * Level.
+ *
+ * @param message
+ * the message object to log
*/
-
/**
* Log a message string at the ERROR level.
- *
- * @param message the message string to log.
+ *
+ * @param message
+ * the message string to log.
*/
public void error(String message) {
- if(repository.isDisabled(Level.ERROR_INT))
+ if (repository.isDisabled(Level.ERROR_INT))
return;
- if(Level.ERROR.isGreaterOrEqual(this.getEffectiveLevel()))
+ if (Level.ERROR.isGreaterOrEqual(this.getEffectiveLevel()))
forcedLog(FQCN, Level.ERROR, message, null);
}
@@ -328,16 +365,18 @@
error(message.toString());
}
-
- /**
- * Log a message at the <code>ERROR</code> level with message
- * formatting done according to the value of
- * <code>format</code> and the <code>arg</code> parameters.
- *
- * <p>This form avoids superflous parameter construction.
+ /**
+ * Log a message at the <code>ERROR</code> level with message formatting
+ * done according to the value of <code>format</code> and the
+ * <code>arg</code> parameters.
*
- * @param format the format
- * @param arg the argument for substitution
+ * <p>
+ * This form avoids superflous parameter construction.
+ *
+ * @param format
+ * the format
+ * @param arg
+ * the argument for substitution
*/
public void error(String format, Object arg) {
if (repository.isDisabled(Level.ERROR_INT)) {
@@ -346,19 +385,23 @@
if (Level.ERROR.isGreaterOrEqual(this.getEffectiveLevel())) {
String msgStr = MessageFormatter.format(format, arg);
- forcedLog(FQCN, Level.ERROR, msgStr, null);
+ forcedLog(FQCN, Level.ERROR, msgStr, null);
}
}
-
- /**
- * Log a message at the ERROR level according to the specified
- * format and arguments.
- *
- * <p> This form avoids superflous object creations.
- *
- * @param format the format
- * @param arg1 the first argument
- * @param arg2 the second argument
+
+ /**
+ * Log a message at the ERROR level according to the specified format and
+ * arguments.
+ *
+ * <p>
+ * This form avoids superflous object creations.
+ *
+ * @param format
+ * the format
+ * @param arg1
+ * the first argument
+ * @param arg2
+ * the second argument
*/
public void error(String format, Object arg1, Object arg2) {
if (repository.isDisabled(Level.ERROR_INT)) {
@@ -371,45 +414,67 @@
}
/**
- * Log an exception (throwable) at the ERROR level with an
- * accompanying message.
- *
- * @param message the message accompanying the exception
- * @param t the exception (throwable) to log, including its stack
- * trace.
+ * Log a message at the ERROR level according to the specified format and
+ * arguments.
+ *
+ * <p>
+ * This form avoids superflous object creations.
+ *
+ * @param format
+ * the format
+ * @param argArray
+ * an array of arguments
+ */
+ public void error(String format, Object argArray[]) {
+ if (repository.isDisabled(Level.ERROR_INT)) {
+ return;
+ }
+
+ if (Level.ERROR.isGreaterOrEqual(this.getEffectiveLevel())) {
+ String msgStr = MessageFormatter.arrayFormat(format, argArray);
+ forcedLog(FQCN, Level.ERROR, msgStr, null);
+ }
+ }
+
+ /**
+ * Log an exception (throwable) at the ERROR level with an accompanying
+ * message.
+ *
+ * @param message
+ * the message accompanying the exception
+ * @param t
+ * the exception (throwable) to log, including its stack trace.
*/
public void error(String message, Throwable t) {
- if(repository.isDisabled(Level.ERROR_INT))
+ if (repository.isDisabled(Level.ERROR_INT))
return;
- if(Level.ERROR.isGreaterOrEqual(this.getEffectiveLevel()))
+ if (Level.ERROR.isGreaterOrEqual(this.getEffectiveLevel()))
forcedLog(FQCN, Level.ERROR, message, t);
}
-
/**
- If the named category exists (in the default hierarchy) then it
- returns a reference to the category, otherwise it returns
- <code>null</code>.
-
- @deprecated Please use [EMAIL PROTECTED] LogManager#exists} instead.
-
- @since 0.8.5 */
- public
- static
- Logger exists(String name) {
+ * If the named category exists (in the default hierarchy) then it returns a
+ * reference to the category, otherwise it returns <code>null</code>.
+ *
+ * @deprecated Please use [EMAIL PROTECTED] LogManager#exists} instead.
+ *
+ * @since 0.8.5
+ */
+ public static Logger exists(String name) {
return LogManager.exists(name);
}
/**
* Log a message string at the FATAL level.
- *
- * @param message the message string to log.
+ *
+ * @param message
+ * the message string to log.
*/
public void fatal(String message) {
- if(repository.isDisabled(Level.FATAL_INT))
+ if (repository.isDisabled(Level.FATAL_INT))
return;
- if(Level.FATAL.isGreaterOrEqual(this.getEffectiveLevel()))
+ if (Level.FATAL.isGreaterOrEqual(this.getEffectiveLevel()))
forcedLog(FQCN, Level.FATAL, message, null);
}
@@ -420,254 +485,241 @@
fatal(message.toString());
}
-
/**
- * Log an exception (throwable) at the FATAL level with an
- * accompanying message.
- *
- * @param message the message accompanying the exception
- * @param t the exception (throwable) to log, including its stack
- * trace.
+ * Log an exception (throwable) at the FATAL level with an accompanying
+ * message.
+ *
+ * @param message
+ * the message accompanying the exception
+ * @param t
+ * the exception (throwable) to log, including its stack trace.
*/
public void fatal(String message, Throwable t) {
- if(repository.isDisabled(Level.FATAL_INT))
+ if (repository.isDisabled(Level.FATAL_INT))
return;
- if(Level.FATAL.isGreaterOrEqual(this.getEffectiveLevel()))
+ if (Level.FATAL.isGreaterOrEqual(this.getEffectiveLevel()))
forcedLog(FQCN, Level.FATAL, message, t);
}
-
/**
- This method creates a new logging event and logs the event
- without further checks. */
- protected void forcedLog(String fqcn, Priority level, Object message,
Throwable t) {
+ * This method creates a new logging event and logs the event without further
+ * checks.
+ */
+ protected void forcedLog(String fqcn, Priority level, Object message,
+ Throwable t) {
callAppenders(new LoggingEvent(fqcn, this, level, message, t));
}
-
/**
- Get the additivity flag for this Category instance.
- */
+ * Get the additivity flag for this Category instance.
+ */
public boolean getAdditivity() {
return additive;
}
/**
- Get the appenders contained in this category as an [EMAIL PROTECTED]
- Enumeration}. If no appenders can be found, then a [EMAIL PROTECTED]
NullEnumeration}
- is returned.
-
- @return Enumeration An enumeration of the appenders in this category. */
- synchronized public Enumeration getAllAppenders() {
- if(aai == null)
+ * Get the appenders contained in this category as an [EMAIL PROTECTED]
Enumeration}. If
+ * no appenders can be found, then a [EMAIL PROTECTED] NullEnumeration} is
returned.
+ *
+ * @return Enumeration An enumeration of the appenders in this category.
+ */
+ synchronized public Enumeration getAllAppenders() {
+ if (aai == null)
return NullEnumeration.getInstance();
else
return aai.getAllAppenders();
}
/**
- Look for the appender named as <code>name</code>.
-
- <p>Return the appender with that name if in the list. Return
- <code>null</code> otherwise. */
+ * Look for the appender named as <code>name</code>.
+ *
+ * <p>
+ * Return the appender with that name if in the list. Return
<code>null</code>
+ * otherwise.
+ */
synchronized public Appender getAppender(String name) {
- if(aai == null || name == null)
+ if (aai == null || name == null)
return null;
- return aai.getAppender(name);
+ return aai.getAppender(name);
}
/**
- Starting from this category, search the category hierarchy for a
- non-null level and return it. Otherwise, return the level of the
- root category.
-
- <p>The Category class is designed so that this method executes as
- quickly as possible.
+ * Starting from this category, search the category hierarchy for a non-null
+ * level and return it. Otherwise, return the level of the root category.
+ *
+ * <p>
+ * The Category class is designed so that this method executes as quickly as
+ * possible.
*/
public Level getEffectiveLevel() {
- for(Category c = this; c != null; c=c.parent) {
- if(c.level != null)
- return c.level;
+ for (Category c = this; c != null; c = c.parent) {
+ if (c.level != null)
+ return c.level;
}
return null; // If reached will cause an NullPointerException.
}
/**
- *
- * @deprecated Please use the the [EMAIL PROTECTED] #getEffectiveLevel}
method
- * instead.
- * */
+ *
+ * @deprecated Please use the the [EMAIL PROTECTED] #getEffectiveLevel}
method instead.
+ */
public Priority getChainedPriority() {
- for(Category c = this; c != null; c=c.parent) {
- if(c.level != null)
- return c.level;
+ for (Category c = this; c != null; c = c.parent) {
+ if (c.level != null)
+ return c.level;
}
return null; // If reached will cause an NullPointerException.
}
-
/**
- Returns all the currently defined categories in the default
- hierarchy as an [EMAIL PROTECTED] java.util.Enumeration Enumeration}.
-
- <p>The root category is <em>not</em> included in the returned
- [EMAIL PROTECTED] Enumeration}.
-
- @deprecated Please use [EMAIL PROTECTED] LogManager#getCurrentLoggers()}
instead.
- */
+ * Returns all the currently defined categories in the default hierarchy as
an
+ * [EMAIL PROTECTED] java.util.Enumeration Enumeration}.
+ *
+ * <p>
+ * The root category is <em>not</em> included in the returned
+ * [EMAIL PROTECTED] Enumeration}.
+ *
+ * @deprecated Please use [EMAIL PROTECTED] LogManager#getCurrentLoggers()}
instead.
+ */
public static Enumeration getCurrentCategories() {
return LogManager.getCurrentLoggers();
}
-
/**
- Return the default Hierarchy instance.
-
- @deprecated Please use [EMAIL PROTECTED]
LogManager#getLoggerRepository()} instead.
-
- @since 1.0
- */
+ * Return the default Hierarchy instance.
+ *
+ * @deprecated Please use [EMAIL PROTECTED]
LogManager#getLoggerRepository()} instead.
+ *
+ * @since 1.0
+ */
public static LoggerRepository getDefaultHierarchy() {
return LogManager.getLoggerRepository();
}
/**
- Return the the [EMAIL PROTECTED] Hierarchy} where this
<code>Category</code>
- instance is attached.
-
- @deprecated Please use [EMAIL PROTECTED] #getLoggerRepository} instead.
-
- @since 1.1 */
- public LoggerRepository getHierarchy() {
+ * Return the the [EMAIL PROTECTED] Hierarchy} where this
<code>Category</code>
+ * instance is attached.
+ *
+ * @deprecated Please use [EMAIL PROTECTED] #getLoggerRepository} instead.
+ *
+ * @since 1.1
+ */
+ public LoggerRepository getHierarchy() {
return repository;
}
/**
- Return the the [EMAIL PROTECTED] LoggerRepository} where this
- <code>Category</code> is attached.
-
- @since 1.2 */
- public LoggerRepository getLoggerRepository() {
+ * Return the the [EMAIL PROTECTED] LoggerRepository} where this
<code>Category</code>
+ * is attached.
+ *
+ * @since 1.2
+ */
+ public LoggerRepository getLoggerRepository() {
return repository;
}
-
- /**
- * @deprecated Make sure to use [EMAIL PROTECTED] Logger#getLogger(String)}
instead.
- */
+ /**
+ * @deprecated Make sure to use [EMAIL PROTECTED] Logger#getLogger(String)}
instead.
+ */
public static Category getInstance(String name) {
return LogManager.getLogger(name);
}
- /**
- * @deprecated Please make sure to use [EMAIL PROTECTED]
Logger#getLogger(Class)} instead.
- */
+ /**
+ * @deprecated Please make sure to use [EMAIL PROTECTED]
Logger#getLogger(Class)}
+ * instead.
+ */
public static Category getInstance(Class clazz) {
return LogManager.getLogger(clazz);
}
-
/**
- Return the category name. */
+ * Return the category name.
+ */
public final String getName() {
return name;
}
-
/**
- Returns the parent of this category. Note that the parent of a
- given category may change during the lifetime of the category.
-
- <p>The root category will return <code>null</code>.
-
- @since 1.2
- */
- final
- public
- Category getParent() {
+ * Returns the parent of this category. Note that the parent of a given
+ * category may change during the lifetime of the category.
+ *
+ * <p>
+ * The root category will return <code>null</code>.
+ *
+ * @since 1.2
+ */
+ final public Category getParent() {
return this.parent;
}
-
/**
- Returns the assigned [EMAIL PROTECTED] Level}, if any, for this Category.
-
- @return Level - the assigned Level, can be <code>null</code>.
- */
- final
- public
- Level getLevel() {
+ * Returns the assigned [EMAIL PROTECTED] Level}, if any, for this Category.
+ *
+ * @return Level - the assigned Level, can be <code>null</code>.
+ */
+ final public Level getLevel() {
return this.level;
}
/**
- @deprecated Please use [EMAIL PROTECTED] #getLevel} instead.
- */
- final
- public
- Level getPriority() {
+ * @deprecated Please use [EMAIL PROTECTED] #getLevel} instead.
+ */
+ final public Level getPriority() {
return this.level;
}
-
/**
- * @deprecated Please use [EMAIL PROTECTED] Logger#getRootLogger()} instead.
+ * @deprecated Please use [EMAIL PROTECTED] Logger#getRootLogger()} instead.
*/
- final
- public
- static
- Category getRoot() {
+ final public static Category getRoot() {
return LogManager.getRootLogger();
}
/**
- Return the <em>inherited</em> [EMAIL PROTECTED] ResourceBundle} for this
- category.
-
- <p>This method walks the hierarchy to find the appropriate
- resource bundle. It will return the resource bundle attached to
- the closest ancestor of this category, much like the way
- priorities are searched. In case there is no bundle in the
- hierarchy then <code>null</code> is returned.
-
- @since 0.9.0 */
- public
- ResourceBundle getResourceBundle() {
- for(Category c = this; c != null; c=c.parent) {
- if(c.resourceBundle != null)
- return c.resourceBundle;
+ * Return the <em>inherited</em> [EMAIL PROTECTED] ResourceBundle} for this
category.
+ *
+ * <p>
+ * This method walks the hierarchy to find the appropriate resource bundle.
It
+ * will return the resource bundle attached to the closest ancestor of this
+ * category, much like the way priorities are searched. In case there is no
+ * bundle in the hierarchy then <code>null</code> is returned.
+ *
+ * @since 0.9.0
+ */
+ public ResourceBundle getResourceBundle() {
+ for (Category c = this; c != null; c = c.parent) {
+ if (c.resourceBundle != null)
+ return c.resourceBundle;
}
// It might be the case that there is no resource bundle
return null;
}
/**
- Returns the string resource coresponding to <code>key</code> in
- this category's inherited resource bundle. See also [EMAIL PROTECTED]
- #getResourceBundle}.
-
- <p>If the resource cannot be found, then an [EMAIL PROTECTED] #error
error}
- message will be logged complaining about the missing resource.
- */
- protected
- String getResourceBundleString(String key) {
+ * Returns the string resource coresponding to <code>key</code> in this
+ * category's inherited resource bundle. See also [EMAIL PROTECTED]
#getResourceBundle}.
+ *
+ * <p>
+ * If the resource cannot be found, then an [EMAIL PROTECTED] #error error}
message will
+ * be logged complaining about the missing resource.
+ */
+ protected String getResourceBundleString(String key) {
ResourceBundle rb = getResourceBundle();
// This is one of the rare cases where we can use logging in order
// to report errors from within log4j.
- if(rb == null) {
- //if(!hierarchy.emittedNoResourceBundleWarning) {
- //error("No resource bundle has been set for category "+name);
- //hierarchy.emittedNoResourceBundleWarning = true;
- //}
+ if (rb == null) {
+ // if(!hierarchy.emittedNoResourceBundleWarning) {
+ // error("No resource bundle has been set for category "+name);
+ // hierarchy.emittedNoResourceBundleWarning = true;
+ // }
return null;
- }
- else {
+ } else {
try {
return rb.getString(key);
- }
- catch(MissingResourceException mre) {
- error("No resource is associated with key \""+key+"\".");
+ } catch (MissingResourceException mre) {
+ error("No resource is associated with key \"" + key + "\".");
return null;
}
}
@@ -675,17 +727,17 @@
/**
* Log a message object with the INFO Level.
- *
- * @param message the message object to log
+ *
+ * @param message
+ * the message object to log
*/
public void info(String message) {
- if(repository.isDisabled(Level.INFO_INT))
+ if (repository.isDisabled(Level.INFO_INT))
return;
- if(Level.INFO.isGreaterOrEqual(this.getEffectiveLevel()))
+ if (Level.INFO.isGreaterOrEqual(this.getEffectiveLevel()))
forcedLog(FQCN, Level.INFO, message, null);
}
-
/**
* @deprecated Please use [EMAIL PROTECTED] #info(String)} method instead.
*/
@@ -694,35 +746,42 @@
}
/**
- * Log a message at the <code>INFO</code> level with message
- * formatting done according to the value of
- * <code>format</code> and the <code>arg</code> parameters.
- *
- * <p>This form avoids superflous parameter construction.
+ * Log a message at the <code>INFO</code> level with message formatting done
+ * according to the value of <code>format</code> and the <code>arg</code>
+ * parameters.
+ *
+ * <p>
+ * This form avoids superflous parameter construction.
*
- * @param format the format
- * @param arg the argument for substitution
+ * @param format
+ * the format
+ * @param arg
+ * the argument for substitution
*/
public void info(String format, Object arg) {
if (repository.isDisabled(Level.INFO_INT)) {
return;
}
- if (Level.INFO.isGreaterOrEqual(this.getEffectiveLevel())) {
+ if (Level.INFO.isGreaterOrEqual(this.getEffectiveLevel())) {
String msgStr = MessageFormatter.format(format, arg);
- forcedLog(FQCN, Level.INFO, msgStr, null);
+ forcedLog(FQCN, Level.INFO, msgStr, null);
}
}
-
+
/**
- * Log a message at the INFO level according to the specified
- * format and arguments.
- *
- * <p> This form avoids superflous object creations.
- *
- * @param format the format
- * @param arg1 the first argument
- * @param arg2 the second argument
+ * Log a message at the INFO level according to the specified format and
+ * arguments.
+ *
+ * <p>
+ * This form avoids superflous object creations.
+ *
+ * @param format
+ * the format
+ * @param arg1
+ * the first argument
+ * @param arg2
+ * the second argument
*/
public void info(String format, Object arg1, Object arg2) {
if (repository.isDisabled(Level.INFO_INT)) {
@@ -735,25 +794,49 @@
}
/**
- * Log an exception (throwable) at the INFO level with an
- * accompanying message.
- *
- * @param message the message accompanying the exception
- * @param t the exception (throwable) to log, including its stack
- * trace.
+ * Log a message at the INFO level according to the specified format and
+ * arguments.
+ *
+ * <p>
+ * This form avoids superflous object creations.
+ *
+ * @param format
+ * the format
+ * @param argArray
+ * an array of arguments
+ */
+ public void info(String format, Object argArray[]) {
+ if (repository.isDisabled(Level.INFO_INT)) {
+ return;
+ }
+
+ if (Level.INFO.isGreaterOrEqual(this.getEffectiveLevel())) {
+ String msgStr = MessageFormatter.arrayFormat(format, argArray);
+ forcedLog(FQCN, Level.INFO, msgStr, null);
+ }
+ }
+
+ /**
+ * Log an exception (throwable) at the INFO level with an accompanying
+ * message.
+ *
+ * @param message
+ * the message accompanying the exception
+ * @param t
+ * the exception (throwable) to log, including its stack trace.
*/
public void info(String message, Throwable t) {
- if(repository.isDisabled(Level.INFO_INT))
+ if (repository.isDisabled(Level.INFO_INT))
return;
- if(Level.INFO.isGreaterOrEqual(this.getEffectiveLevel()))
+ if (Level.INFO.isGreaterOrEqual(this.getEffectiveLevel()))
forcedLog(FQCN, Level.INFO, message, t);
}
/**
- Is the appender passed as parameter attached to this category?
+ * Is the appender passed as parameter attached to this category?
*/
public boolean isAttached(Appender appender) {
- if(appender == null || aai == null)
+ if (appender == null || aai == null)
return false;
else {
return aai.isAttached(appender);
@@ -761,188 +844,194 @@
}
/**
- * Check whether this category is enabled for the <code>DEBUG</code>
- * Level.
- *
- * <p> This function is intended to lessen the computational cost of
- * disabled log debug statements.
- *
- * <p> For some <code>cat</code> Category object, when you write,
- * <pre>
- * cat.debug("This is entry number: " + i );
- * </pre>
- *
- * <p>You incur the cost constructing the message, concatenatiion in
- * this case, regardless of whether the message is logged or not.
- *
- * <p>If you are worried about speed, then you should write
- * <pre>
- * if(cat.isDebugEnabled()) {
- * cat.debug("This is entry number: " + i );
- * }
- * </pre>
- *
- * <p>This way you will not incur the cost of parameter
- * construction if debugging is disabled for <code>cat</code>. On
- * the other hand, if the <code>cat</code> is debug enabled, you
- * will incur the cost of evaluating whether the category is debug
- * enabled twice. Once in <code>isDebugEnabled</code> and once in
- * the <code>debug</code>. This is an insignificant overhead
- * since evaluating a category takes about 1%% of the time it
- * takes to actually log.
- *
- * @return boolean - <code>true</code> if this category is debug
- * enabled, <code>false</code> otherwise.
- * */
+ * Check whether this category is enabled for the <code>DEBUG</code> Level.
+ *
+ * <p>
+ * This function is intended to lessen the computational cost of disabled log
+ * debug statements.
+ *
+ * <p>
+ * For some <code>cat</code> Category object, when you write,
+ *
+ * <pre>
+ * cat.debug("This is entry number: " + i);
+ * </pre>
+ *
+ * <p>
+ * You incur the cost constructing the message, concatenatiion in this case,
+ * regardless of whether the message is logged or not.
+ *
+ * <p>
+ * If you are worried about speed, then you should write
+ *
+ * <pre>
+ * if (cat.isDebugEnabled()) {
+ * cat.debug("This is entry number: " + i);
+ * }
+ * </pre>
+ *
+ * <p>
+ * This way you will not incur the cost of parameter construction if
debugging
+ * is disabled for <code>cat</code>. On the other hand, if the
+ * <code>cat</code> is debug enabled, you will incur the cost of evaluating
+ * whether the category is debug enabled twice. Once in
+ * <code>isDebugEnabled</code> and once in the <code>debug</code>. This
+ * is an insignificant overhead since evaluating a category takes about 1%%
of
+ * the time it takes to actually log.
+ *
+ * @return boolean - <code>true</code> if this category is debug enabled,
+ * <code>false</code> otherwise.
+ */
public boolean isDebugEnabled() {
- if(repository.isDisabled( Level.DEBUG_INT))
+ if (repository.isDisabled(Level.DEBUG_INT))
return false;
return Level.DEBUG.isGreaterOrEqual(this.getEffectiveLevel());
}
/**
- Check whether this category is enabled for a given [EMAIL PROTECTED]
- Level} passed as parameter.
-
- See also [EMAIL PROTECTED] #isDebugEnabled}.
-
- @return boolean True if this category is enabled for <code>level</code>.
- */
+ * Check whether this category is enabled for a given [EMAIL PROTECTED]
Level} passed as
+ * parameter.
+ *
+ * See also [EMAIL PROTECTED] #isDebugEnabled}.
+ *
+ * @return boolean True if this category is enabled for <code>level</code>.
+ */
public boolean isEnabledFor(Priority level) {
- if(repository.isDisabled(level.level))
+ if (repository.isDisabled(level.level))
return false;
return level.isGreaterOrEqual(this.getEffectiveLevel());
}
/**
- Check whether this category is enabled for the info Level.
- See also [EMAIL PROTECTED] #isDebugEnabled}.
-
- @return boolean - <code>true</code> if this category is enabled
- for level info, <code>false</code> otherwise.
- */
+ * Check whether this category is enabled for the info Level. See also
+ * [EMAIL PROTECTED] #isDebugEnabled}.
+ *
+ * @return boolean - <code>true</code> if this category is enabled for level
+ * info, <code>false</code> otherwise.
+ */
public boolean isInfoEnabled() {
- if(repository.isDisabled(Level.INFO_INT))
+ if (repository.isDisabled(Level.INFO_INT))
return false;
return Level.INFO.isGreaterOrEqual(this.getEffectiveLevel());
}
/**
- Check whether this category is enabled for the info Level.
- See also [EMAIL PROTECTED] #isDebugEnabled}.
-
- @return boolean - <code>true</code> if this category is enabled
- for level WARN, <code>false</code> otherwise.
- @since 1.2.10
- */
+ * Check whether this category is enabled for the info Level. See also
+ * [EMAIL PROTECTED] #isDebugEnabled}.
+ *
+ * @return boolean - <code>true</code> if this category is enabled for level
+ * WARN, <code>false</code> otherwise.
+ * @since 1.2.10
+ */
public boolean isWarnEnabled() {
- if(repository.isDisabled(Level.WARN_INT))
+ if (repository.isDisabled(Level.WARN_INT))
return false;
return Level.WARN.isGreaterOrEqual(this.getEffectiveLevel());
}
/**
- Check whether this category is enabled for the info Level.
- See also [EMAIL PROTECTED] #isDebugEnabled}.
-
- @return boolean - <code>true</code> if this category is enabled
- for level ERROR, <code>false</code> otherwise.
- @since 1.2.10
- */
+ * Check whether this category is enabled for the info Level. See also
+ * [EMAIL PROTECTED] #isDebugEnabled}.
+ *
+ * @return boolean - <code>true</code> if this category is enabled for level
+ * ERROR, <code>false</code> otherwise.
+ * @since 1.2.10
+ */
public boolean isErrorEnabled() {
- if(repository.isDisabled(Level.ERROR_INT))
+ if (repository.isDisabled(Level.ERROR_INT))
return false;
return Level.ERROR.isGreaterOrEqual(this.getEffectiveLevel());
}
/**
- Log a localized message. The user supplied parameter
- <code>key</code> is replaced by its localized version from the
- resource bundle.
-
- @see #setResourceBundle
-
- @since 0.8.4 */
- public
- void l7dlog(Priority priority, String key, Throwable t) {
- if(repository.isDisabled(priority.level)) {
+ * Log a localized message. The user supplied parameter <code>key</code> is
+ * replaced by its localized version from the resource bundle.
+ *
+ * @see #setResourceBundle
+ *
+ * @since 0.8.4
+ */
+ public void l7dlog(Priority priority, String key, Throwable t) {
+ if (repository.isDisabled(priority.level)) {
return;
}
- if(priority.isGreaterOrEqual(this.getEffectiveLevel())) {
+ if (priority.isGreaterOrEqual(this.getEffectiveLevel())) {
String msg = getResourceBundleString(key);
// if message corresponding to 'key' could not be found in the
// resource bundle, then default to 'key'.
- if(msg == null) {
- msg = key;
+ if (msg == null) {
+ msg = key;
}
forcedLog(FQCN, priority, msg, t);
}
}
+
/**
- Log a localized and parameterized message. First, the user
- supplied <code>key</code> is searched in the resource
- bundle. Next, the resulting pattern is formatted using
- [EMAIL PROTECTED] java.text.MessageFormat#format(String,Object[])} method
with the
- user supplied object array <code>params</code>.
-
- @since 0.8.4
- */
- public
- void l7dlog(Priority priority, String key, Object[] params, Throwable t) {
- if(repository.isDisabled(priority.level)) {
+ * Log a localized and parameterized message. First, the user supplied
+ * <code>key</code> is searched in the resource bundle. Next, the resulting
+ * pattern is formatted using
+ * [EMAIL PROTECTED] java.text.MessageFormat#format(String,Object[])} method
with the
+ * user supplied object array <code>params</code>.
+ *
+ * @since 0.8.4
+ */
+ public void l7dlog(Priority priority, String key, Object[] params, Throwable
t) {
+ if (repository.isDisabled(priority.level)) {
return;
}
- if(priority.isGreaterOrEqual(this.getEffectiveLevel())) {
+ if (priority.isGreaterOrEqual(this.getEffectiveLevel())) {
String pattern = getResourceBundleString(key);
String msg;
- if(pattern == null)
- msg = key;
+ if (pattern == null)
+ msg = key;
else
- msg = java.text.MessageFormat.format(pattern, params);
+ msg = java.text.MessageFormat.format(pattern, params);
forcedLog(FQCN, priority, msg, t);
}
}
/**
- This generic form is intended to be used by wrappers.
+ * This generic form is intended to be used by wrappers.
*/
- public
- void log(Priority priority, Object message, Throwable t) {
- if(repository.isDisabled(priority.level)) {
+ public void log(Priority priority, Object message, Throwable t) {
+ if (repository.isDisabled(priority.level)) {
return;
}
- if(priority.isGreaterOrEqual(this.getEffectiveLevel()))
+ if (priority.isGreaterOrEqual(this.getEffectiveLevel()))
forcedLog(FQCN, priority, message, t);
}
- /**
- This generic form is intended to be used by wrappers.
- */
- public
- void log(Priority priority, String message) {
- if(repository.isDisabled(priority.level)) {
+ /**
+ * This generic form is intended to be used by wrappers.
+ */
+ public void log(Priority priority, String message) {
+ if (repository.isDisabled(priority.level)) {
return;
}
- if(priority.isGreaterOrEqual(this.getEffectiveLevel()))
+ if (priority.isGreaterOrEqual(this.getEffectiveLevel()))
forcedLog(FQCN, priority, message, null);
}
/**
-
- This is the most generic printing method. It is intended to be
- invoked by <b>wrapper</b> classes.
-
- @param callerFQCN The wrapper class' fully qualified class name.
- @param level The level of the logging request.
- @param message The message of the logging request.
- @param t The throwable of the logging request, may be null. */
- public
- void log(String callerFQCN, Priority level, Object message, Throwable t) {
- if(repository.isDisabled(level.level)) {
+ *
+ * This is the most generic printing method. It is intended to be invoked by
+ * <b>wrapper</b> classes.
+ *
+ * @param callerFQCN
+ * The wrapper class' fully qualified class name.
+ * @param level
+ * The level of the logging request.
+ * @param message
+ * The message of the logging request.
+ * @param t
+ * The throwable of the logging request, may be null.
+ */
+ public void log(String callerFQCN, Priority level, Object message, Throwable
t) {
+ if (repository.isDisabled(level.level)) {
return;
}
- if(level.isGreaterOrEqual(this.getEffectiveLevel())) {
- if(message instanceof String) {
+ if (level.isGreaterOrEqual(this.getEffectiveLevel())) {
+ if (message instanceof String) {
forcedLog(callerFQCN, level, message, t);
} else {
forcedLog(callerFQCN, level, message.toString(), t);
@@ -950,146 +1039,139 @@
}
}
-
/**
- Remove all previously added appenders from this Category
- instance.
-
- <p>This is useful when re-reading configuration information.
- */
- synchronized
- public
- void removeAllAppenders() {
- if(aai != null) {
+ * Remove all previously added appenders from this Category instance.
+ *
+ * <p>
+ * This is useful when re-reading configuration information.
+ */
+ synchronized public void removeAllAppenders() {
+ if (aai != null) {
aai.removeAllAppenders();
aai = null;
}
}
/**
- Remove the appender passed as parameter form the list of appenders.
-
- @since 0.8.2
- */
- synchronized
- public
- void removeAppender(Appender appender) {
- if(appender == null || aai == null)
+ * Remove the appender passed as parameter form the list of appenders.
+ *
+ * @since 0.8.2
+ */
+ synchronized public void removeAppender(Appender appender) {
+ if (appender == null || aai == null)
return;
aai.removeAppender(appender);
}
/**
- Remove the appender with the name passed as parameter form the
- list of appenders.
-
- @since 0.8.2 */
- synchronized
- public
- void removeAppender(String name) {
- if(name == null || aai == null) return;
+ * Remove the appender with the name passed as parameter form the list of
+ * appenders.
+ *
+ * @since 0.8.2
+ */
+ synchronized public void removeAppender(String name) {
+ if (name == null || aai == null)
+ return;
aai.removeAppender(name);
}
/**
- Set the additivity flag for this Category instance.
- @since 0.8.1
+ * Set the additivity flag for this Category instance.
+ *
+ * @since 0.8.1
*/
- public
- void setAdditivity(boolean additive) {
+ public void setAdditivity(boolean additive) {
this.additive = additive;
}
/**
- Only the Hiearchy class can set the hiearchy of a
- category. Default package access is MANDATORY here. */
- final
- void setHierarchy(LoggerRepository repository) {
+ * Only the Hiearchy class can set the hiearchy of a category. Default
package
+ * access is MANDATORY here.
+ */
+ final void setHierarchy(LoggerRepository repository) {
this.repository = repository;
}
/**
- Set the level of this Category. If you are passing any of
- <code>Level.DEBUG</code>, <code>Level.INFO</code>,
- <code>Level.WARN</code>, <code>Level.ERROR</code>,
- <code>Level.FATAL</code> as a parameter, you need to case them as
- Level.
-
- <p>As in <pre> logger.setLevel((Level) Level.DEBUG);
</pre>
-
-
- <p>Null values are admitted. */
- public
- void setLevel(Level level) {
+ * Set the level of this Category. If you are passing any of
+ * <code>Level.DEBUG</code>, <code>Level.INFO</code>,
+ * <code>Level.WARN</code>, <code>Level.ERROR</code>,
+ * <code>Level.FATAL</code> as a parameter, you need to case them as Level.
+ *
+ * <p>
+ * As in
+ *
+ * <pre>
+ * logger.setLevel((Level) Level.DEBUG);
+ * </pre>
+ *
+ *
+ * <p>
+ * Null values are admitted.
+ */
+ public void setLevel(Level level) {
this.level = level;
}
-
/**
- Set the level of this Category.
-
- <p>Null values are admitted.
-
- @deprecated Please use [EMAIL PROTECTED] #setLevel} instead.
- */
- public
- void setPriority(Priority priority) {
+ * Set the level of this Category.
+ *
+ * <p>
+ * Null values are admitted.
+ *
+ * @deprecated Please use [EMAIL PROTECTED] #setLevel} instead.
+ */
+ public void setPriority(Priority priority) {
this.level = (Level) priority;
}
-
/**
- Set the resource bundle to be used with localized logging
- methods [EMAIL PROTECTED] #l7dlog(Priority,String,Throwable)} and [EMAIL
PROTECTED]
- #l7dlog(Priority,String,Object[],Throwable)}.
-
- @since 0.8.4
+ * Set the resource bundle to be used with localized logging methods
+ * [EMAIL PROTECTED] #l7dlog(Priority,String,Throwable)} and [EMAIL
PROTECTED]
+ * #l7dlog(Priority,String,Object[],Throwable)}.
+ *
+ * @since 0.8.4
*/
- public
- void setResourceBundle(ResourceBundle bundle) {
+ public void setResourceBundle(ResourceBundle bundle) {
resourceBundle = bundle;
}
/**
- Calling this method will <em>safely</em> close and remove all
- appenders in all the categories including root contained in the
- default hierachy.
-
- <p>Some appenders such as [EMAIL PROTECTED]
org.apache.log4j.net.SocketAppender}
- and [EMAIL PROTECTED] AsyncAppender} need to be closed before the
- application exists. Otherwise, pending logging events might be
- lost.
-
- <p>The <code>shutdown</code> method is careful to close nested
- appenders before closing regular appenders. This is allows
- configurations where a regular appender is attached to a category
- and again to a nested appender.
-
- @deprecated Please use [EMAIL PROTECTED] LogManager#shutdown()} instead.
-
- @since 1.0
- */
- public
- static
- void shutdown() {
+ * Calling this method will <em>safely</em> close and remove all appenders
+ * in all the categories including root contained in the default hierachy.
+ *
+ * <p>
+ * Some appenders such as [EMAIL PROTECTED]
org.apache.log4j.net.SocketAppender} and
+ * [EMAIL PROTECTED] AsyncAppender} need to be closed before the application
exists.
+ * Otherwise, pending logging events might be lost.
+ *
+ * <p>
+ * The <code>shutdown</code> method is careful to close nested appenders
+ * before closing regular appenders. This is allows configurations where a
+ * regular appender is attached to a category and again to a nested appender.
+ *
+ * @deprecated Please use [EMAIL PROTECTED] LogManager#shutdown()} instead.
+ *
+ * @since 1.0
+ */
+ public static void shutdown() {
LogManager.shutdown();
}
-
/**
* Log a message object with the WARN Level.
- *
- * @param message the message object to log
+ *
+ * @param message
+ * the message object to log
*/
public void warn(String message) {
- if(repository.isDisabled( Level.WARN_INT))
+ if (repository.isDisabled(Level.WARN_INT))
return;
- if(Level.WARN.isGreaterOrEqual(this.getEffectiveLevel()))
+ if (Level.WARN.isGreaterOrEqual(this.getEffectiveLevel()))
forcedLog(FQCN, Level.WARN, message, null);
}
-
/**
* @deprecated Please use [EMAIL PROTECTED] #warn(String)} method instead.
*/
@@ -1098,14 +1180,17 @@
}
/**
- * Log a message at the <code>WARN</code> level with message
- * formatting done according to the value of
- * <code>format</code> and the <code>arg</code> parameters.
- *
- * <p>This form avoids superflous parameter construction.
+ * Log a message at the <code>WARN</code> level with message formatting done
+ * according to the value of <code>format</code> and the <code>arg</code>
+ * parameters.
*
- * @param format the format
- * @param arg the argument for substitution
+ * <p>
+ * This form avoids superflous parameter construction.
+ *
+ * @param format
+ * the format
+ * @param arg
+ * the argument for substitution
*/
public void warn(String format, Object arg) {
if (repository.isDisabled(Level.WARN_INT)) {
@@ -1114,19 +1199,23 @@
if (Level.WARN.isGreaterOrEqual(this.getEffectiveLevel())) {
String msgStr = MessageFormatter.format(format, arg);
- forcedLog(FQCN, Level.WARN, msgStr, null);
+ forcedLog(FQCN, Level.WARN, msgStr, null);
}
}
/**
- * Log a message at the WARN level according to the specified
- * format and arguments.
- *
- * <p> This form avoids superflous object creations.
- *
- * @param format the format
- * @param arg1 the first argument
- * @param arg2 the second argument
+ * Log a message at the WARN level according to the specified format and
+ * arguments.
+ *
+ * <p>
+ * This form avoids superflous object creations.
+ *
+ * @param format
+ * the format
+ * @param arg1
+ * the first argument
+ * @param arg2
+ * the second argument
*/
public void warn(String format, Object arg1, Object arg2) {
if (repository.isDisabled(Level.WARN_INT)) {
@@ -1137,19 +1226,43 @@
forcedLog(FQCN, Level.WARN, msgStr, null);
}
}
+
+ /**
+ * Log a message at the WARN level according to the specified format and
+ * arguments.
+ *
+ * <p>
+ * This form avoids superflous object creations.
+ *
+ * @param format
+ * the format
+ * @param argArray
+ * an array of arguments
+ */
+ public void warn(String format, Object argArray[]) {
+ if (repository.isDisabled(Level.WARN_INT)) {
+ return;
+ }
+
+ if (Level.WARN.isGreaterOrEqual(this.getEffectiveLevel())) {
+ String msgStr = MessageFormatter.arrayFormat(format, argArray);
+ forcedLog(FQCN, Level.WARN, msgStr, null);
+ }
+ }
/**
- * Log an exception (throwable) at the WARN level with an
- * accompanying message.
- *
- * @param message the message accompanying the exception
- * @param t the exception (throwable) to log, including its stack
- * trace.
+ * Log an exception (throwable) at the WARN level with an accompanying
+ * message.
+ *
+ * @param message
+ * the message accompanying the exception
+ * @param t
+ * the exception (throwable) to log, including its stack trace.
*/
public void warn(String message, Throwable t) {
- if(repository.isDisabled(Level.WARN_INT))
+ if (repository.isDisabled(Level.WARN_INT))
return;
- if(Level.WARN.isGreaterOrEqual(this.getEffectiveLevel()))
+ if (Level.WARN.isGreaterOrEqual(this.getEffectiveLevel()))
forcedLog(FQCN, Level.WARN, message, t);
}
}
_______________________________________________
nlog4j-dev mailing list
[email protected]
http://slf4j.org/mailman/listinfo/nlog4j-dev