From log4j-cvslarryaguilar@example.net Tue Nov 06 23:17:36 2001 Return-Path: <log4j-cvslarryaguilar@example.net> Delivered-To: larryaguilar@example.net Received: (qmail 58322 invoked from network); 6 Nov 2001 23:17:35 -0000 Received: from unknown (HELO osaka.betaversion.org) (83.161.120.155) by daedalus.apache.org with SMTP; 6 Nov 2001 23:17:35 -0000 Received: (qmail 17303 invoked from network); 6 Nov 2001 23:20:06 -0000 Received: from nagoya.betaversion.org (83.161.120.155) by osaka.betaversion.org with SMTP; 6 Nov 2001 23:20:06 -0000 Received: (qmail 4439 invoked by uid 97); 6 Nov 2001 23:17:42 -0000 Delivered-To: larryaguilar@example.net Received: (qmail 4419 invoked by uid 97); 6 Nov 2001 23:17:41 -0000 Mailing-List: contact larryaguilar@example.net; run by ezmlm Precedence: bulk List-Unsubscribe: <mailto:larryaguilar@example.net> List-Subscribe: <mailto:larryaguilar@example.net> List-Help: <mailto:larryaguilar@example.net> List-Post: <mailto:larryaguilar@example.net> List-Id: "Log4J CVS List" <log4j-cvs.jakarta.apache.org> Reply-To: "Log4J Developers List" <larryaguilar@example.net> Delivered-To: mailing list larryaguilar@example.net Received: (qmail 1370 invoked from network); 6 Nov 2001 23:16:16 -0000 Date: 6 Nov 2001 23:04:51 -0000 Message-ID: <larryaguilar@example.net> From: larryaguilar@example.net To: larryaguilar@example.net Subject: cvs commit: jakarta-log4j/src/java/org/apache/log4j FileAppender.java WriterAppender.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ceki 01/11/06 15:04:51 Modified: docs HISTORY critique.html src/java/org/apache/log4j FileAppender.java WriterAppender.java Log: - Added support for different encodings in WriterAppender. Thanks to Ben Sandee for submitting the relevant patch. [*] Revision Changes Path 1.72 +3 -0 jakarta-log4j/docs/HISTORY Index: HISTORY =================================================================== RCS file: /home/cvs/jakarta-log4j/docs/HISTORY,v retrieving revision 1.71 retrieving revision 1.72 diff -u -r1.71 -r1.72 --- HISTORY 2001/10/22 23:08:59 1.71 +++ HISTORY 2001/11/06 23:04:51 1.72 @@ -14,6 +14,9 @@ - Log4j is now configurable using JMX. [*] + - Added support for different encodings in WriterAppender. Thanks to + Ben Sandee for submitting the relevant patch. [*] + - Added the FINE level as an alias for the DEBUG level to make migration from log4j to j.u.l. and vice versa easier. [*] 1.26 +3 -3 jakarta-log4j/docs/critique.html Index: critique.html =================================================================== RCS file: /home/cvs/jakarta-log4j/docs/critique.html,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- critique.html 2001/10/22 23:08:59 1.25 +++ critique.html 2001/11/06 23:04:51 1.26 @@ -550,14 +550,14 @@ <li><p><a href="pub-support/MichaelChermside.html">Michael Chermside</a> <li><p><a href="pub-support/EdoardoComar.html">Edoardo Comar</a> <li><p><a href="pub-support/LeonardReinhart.html">Leonard Reinhart </a> +<li><p><a href="pub-support/JamesMaggs.html">James Maggs</a> +<li><p><a href="pub-support/AlexRojkov.html">Alex Rojkov</a> +<!-- -<!-- -<li><p><a href="pub-support/.html"></a> -<li><p><a href="pub-support/.html"></a> <li><p><a href="pub-support/.html"></a> <li><p><a href="pub-support/.html"></a> <li><p><a href="pub-support/.html"></a> 1.30 +2 -1 jakarta-log4j/src/java/org/apache/log4j/FileAppender.java Index: FileAppender.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/FileAppender.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- FileAppender.java 2001/08/14 21:11:52 1.29 +++ FileAppender.java 2001/11/06 23:04:51 1.30 @@ -10,6 +10,7 @@ import java.io.IOException; import java.io.Writer; import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.OutputStream; import java.io.BufferedWriter; import java.io.OutputStreamWriter; @@ -271,7 +272,7 @@ } reset(); - Writer fw = new FileWriter(fileName, append); + Writer fw = createWriter(new FileOutputStream(fileName, append)); if(bufferedIO) { fw = new BufferedWriter(fw); } 1.18 +45 -1 jakarta-log4j/src/java/org/apache/log4j/WriterAppender.java Index: WriterAppender.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/WriterAppender.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- WriterAppender.java 2001/07/25 19:43:44 1.17 +++ WriterAppender.java 2001/11/06 23:04:51 1.18 @@ -47,6 +47,13 @@ protected boolean immediateFlush = true; /** + The encoding to use when opening an InputStream. <p>The + <code>encoding</code> variable is set to <code>null</null> by + default which results in the utilization of the system's default + encoding. */ + protected String encoding; + + /** This is the {@link QuietWriter quietWriter} where we will write to. */ @@ -189,7 +196,6 @@ writeFooter(); reset(); } - /** Close the underlying {@link java.io.Writer}. */ @@ -204,6 +210,44 @@ } } } + + /** + Returns an OutputStreamWriter when passed an OutputStream. The + encoding used will depend on the value of the + <code>encoding</code> property. If the encoding value is + specified incorrectly the writer will be opened using the default + system encoding (an error message will be printed to the loglog. */ + protected + OutputStreamWriter createWriter(OutputStream os) { + OutputStreamWriter retval = null; + + String enc = getEncoding(); + if(enc != null) { + try { + retval = new OutputStreamWriter(os, enc); + } catch(IOException e) { + LogLog.warn("Error initializing output writer."); + LogLog.warn("Unsupported encoding?"); + } + } + if(retval == null) { + retval = new OutputStreamWriter(os); + } + return retval; + } + + public + String getEncoding() { + return encoding; + } + + public + void setEncoding(String value) { + encoding = value; + } + + + /** Set the {@link ErrorHandler} for this FileAppender and also the -- To unsubscribe, e-mail: <mailto:larryaguilar@example.net> For additional commands, e-mail: <mailto:larryaguilar@example.net> From log4j-cvslarryaguilar@example.net Wed Nov 14 21:33:26 2001 Return-Path: <log4j-cvslarryaguilar@example.net> Delivered-To: larryaguilar@example.net Received: (qmail 19198 invoked from network); 14 Nov 2001 21:33:26 -0000 Received: from unknown (HELO nagoya.betaversion.org) (83.161.120.155) by daedalus.apache.org with SMTP; 14 Nov 2001 21:33:26 -0000 Received: (qmail 1895 invoked by uid 97); 14 Nov 2001 21:28:59 -0000 Delivered-To: larryaguilar@example.net Received: (qmail 1847 invoked by uid 97); 14 Nov 2001 21:28:58 -0000 Mailing-List: contact larryaguilar@example.net; run by ezmlm Precedence: bulk List-Unsubscribe: <mailto:larryaguilar@example.net> List-Subscribe: <mailto:larryaguilar@example.net> List-Help: <mailto:larryaguilar@example.net> List-Post: <mailto:larryaguilar@example.net> List-Id: "Log4J CVS List" <log4j-cvs.jakarta.apache.org> Reply-To: "Log4J Developers List" <larryaguilar@example.net> Delivered-To: mailing list larryaguilar@example.net Received: (qmail 14603 invoked from network); 14 Nov 2001 20:44:41 -0000 Date: 14 Nov 2001 20:31:15 -0000 Message-ID: <larryaguilar@example.net> From: larryaguilar@example.net To: larryaguilar@example.net Subject: cvs commit: jakarta-log4j/src/java/org/apache/log4j/varia ReloadingPropertyConfigurator.java Makefile PriorityMatchFilter.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ceki 01/11/14 12:31:15 Modified: src/docbook architecture.xml configuration.xml src/java/org/apache/log4j/varia Makefile PriorityMatchFilter.java Added: src/java/org/apache/log4j/varia ReloadingPropertyConfigurator.java Log: - Doc enhacements - Added ReloadingPropertyConfigurator which performs a function similar to PropertyConfigurator.configureAndWatch() Revision Changes Path 1.15 +198 -169 jakarta-log4j/src/docbook/architecture.xml Index: architecture.xml =================================================================== RCS file: /home/cvs/jakarta-log4j/src/docbook/architecture.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- architecture.xml 2001/10/17 20:59:49 1.14 +++ architecture.xml 2001/11/14 20:31:14 1.15 @@ -20,7 +20,10 @@ <classname>java.util.logging</classname> API introduced in JDK 1.4, will recognize that log4j's architecture is <emphasis>very</emphasis> similar although log4j offers much more - functionality and is compatible with JDK 1.1 and later. + functionality and is compatible with JDK 1.1 and later. Most of + the concepts outlined in this document are reproduced in + <classname>java.util.logging</classname> with somewhat different + names. </para> </note> @@ -58,10 +61,11 @@ <para>A logger is said to be an <emphasis>ancestor</emphasis> of another logger if its name followed by a dot is a prefix of the - <emphasis>descendant</emphasis> logger name. A logger is - said to be a <emphasis>parent</emphasis> of a - <emphasis>child</emphasis> logger if there are no other - ancestors between itself and the descendant logger. + <emphasis>descendant</emphasis> logger name. A logger + which is an immediate ancestor of a descendant is said + to be a <emphasis>parent</emphasis> logger and the + immediate descendant is said to be a + <emphasis>child</emphasis> logger. </para> </listitem> </varlistentry> @@ -88,6 +92,7 @@ <listitem><para>it cannot be retrieved by name.</para></listitem> </itemizedlist> </para> + <para>Invoking the class static <ulink url="../api/org/apache/log4j/Logger.html#getRootLogger()">Logger.getRootLogger</ulink> @@ -123,40 +128,112 @@ </programlisting> </para> - <para>Loggers <emphasis>may</emphasis> be assigned levels. The - set of possible levels, that is - - <ulink url="../api/org/apache/log4j/Level.html#DEBUG">DEBUG</ulink>, - <ulink url="../api/org/apache/log4j/Level.html#INFO">INFO</ulink>, - <ulink url="../api/org/apache/log4j/Level.html#WARN">WARN</ulink>, - <ulink url="../api/org/apache/log4j/Level.html#ERROR">ERROR</ulink> and - <ulink url="../api/org/apache/log4j/Level.html#FATAL">FATAL</ulink> + <sect2> + <title>Logger creation and retrieval</title> + + <para>Each and every logger belongs to the repository that + creates it. As mentioned previously, all non-root loggers are + instantiated and retrieved with the class static <ulink + url="../api/org/apache/log4j/Logger.html#geLogger()">Logger.getLogger</ulink> + method. This method actually delegates its work to the + appropriate logger repository. In other words, it is the + repository which takes care of the creation and retrieval of + logger instances. Log4j comes with a particular type of + repository, called the hierarchy, which arranges loggers + according to the named-hierarchy rule. The only type of + repository encoutered in practice is the hierarchy. As such, + unless specified otherwise, we will use the terms hiearchy and + repository interchangeably in the remainder of this document. + </para> + + <para>Calling the <varname>getLogger</varname> method with the + same name will always return a reference to the exact same + logger object. + </para> - are defined in the <ulink - url="../api/org/apache/log4j/Level.html">org.apache.log4j.Level</ulink> - class. Although we do not encourage it, you may define your - own levels by sub-classing the <classname>Level</classname> - class. Possibly a better approach is will be explained later - on. - </para> + <para>For example, in</para> + + <para><programlisting> + Logger x = Logger.getLogger("wombat"); + Logger y = Logger.getLogger("wombat");</programlisting></para> + + <para> + <varname>x</varname> and <varname>y</varname> refer to + <emphasis>exactly</emphasis> the same logger object. + </para> - <para>The <emphasis>effective level</emphasis> of a logger is - given by its assigned level, if it is assigned one. Otherwise, if - the logger has not been assigned a level, then it inherits the - level of its closest ancestor with an assigned level. More - formally, - </para> + <para>Thus, it is possible to configure a logger and then to + retrieve the same instance somewhere else in the code without + passing around references. In contrast to biological + parenthood, where ancestors always preceed their decendants, + log4j loggers can be created and configured in any order. In + particular, an ancestor logger will find and link to its + descendants even if it is instantiated after them. + </para> + + <para>Configuration of the log4j environment is typically done + at application initialization. The preferred way is by reading + a configuration file. This approach will be discussed in <xref + linkend="configuration"/>. + </para> + <para>Log4j makes it easy to name loggers by <emphasis>software + component</emphasis>. This can be accomplished by + statically instantiating a logger in each class, with the + logger name equal to the fully qualified name of the + class. This is a useful and straightforward method of + defining loggers. As the log output bears the name of the + generating logger, this naming strategy makes it easy to + identify the origin of a log message. However, this is only + one possible, albeit common, strategy for naming + loggers. Log4j does not impose any restriction on the name + of loggers. The user is free to name logger as she + wishes.>Nevertheless, naming loggers after the class where + they are located seems to be the best strategy known so + far. + </para> + </sect2> + + <sect2> + <title>Levels</title> - <para id="inheritanceRule"> + <para>Loggers <emphasis>may</emphasis> be assigned levels. We + say "may" because one of the big advantages of the log4j + architecture is that most loggers do not need to be assigned a + level. This greatly simplifies logging management. The set of + possible levels, that is + + <ulink url="../api/org/apache/log4j/Level.html#DEBUG">DEBUG</ulink>, + <ulink url="../api/org/apache/log4j/Level.html#INFO">INFO</ulink>, + <ulink url="../api/org/apache/log4j/Level.html#WARN">WARN</ulink>, + <ulink url="../api/org/apache/log4j/Level.html#ERROR">ERROR</ulink> and + <ulink url="../api/org/apache/log4j/Level.html#FATAL">FATAL</ulink> + + are defined in the <ulink + url="../api/org/apache/log4j/Level.html">org.apache.log4j.Level</ulink> + class. Although we do not encourage it, you may define your + own levels by sub-classing the <classname>Level</classname> + class. A possibly better approach is will be explained later + on. + </para> + + <para>The <emphasis>effective level</emphasis> of a logger is + given by its assigned level, if it is assigned one. Otherwise, if + the logger has not been assigned a level, then it inherits the + level of its closest ancestor with an assigned level. More + formally, + </para> + + <para id="inheritanceRule"> <variablelist> <varlistentry> <term><emphasis role="strong">Effective level of a Logger</emphasis></term> <listitem> - <para>The <emphasis>effective level</emphasis> of a given - logger <emphasis>L</emphasis>, is equal to the first - non-null level in the logger hierarchy, starting at + <para>The <emphasis>effective</emphasis> or + <emphasis>inherited</emphasis> level of a given logger + <emphasis>L</emphasis>, is equal to the first non-null + level in the logger hierarchy, starting at <emphasis>L</emphasis> and proceeding upwards in the hierarchy towards the root logger. </para> @@ -166,12 +243,12 @@ </para> <para>To ensure that all loggers can eventually inherit a level, - the root logger always has an assigned level.</para> - - <para>Below are four tables with various assigned levels and the - resulting effective levels according to the above rule.</para> - - <para> + the root logger always has an assigned level.</para> + + <para>Below are four tables with various assigned levels and the + resulting effective levels.</para> + + <para> <table> <title>Level Inheritance - Example 1</title> <tgroup cols="3" align="left"> @@ -292,85 +369,85 @@ </tgroup> </table> </para> - - <para>In example 3, the loggers <varname>root</varname>, - <varname>X</varname> and <varname>X.Y.Z</varname> are assigned - the levels <varname>INFO</varname>, <varname>DEBUG</varname> - and <varname>WARN</varname> respectively. The logger - <varname>X.Y</varname> inherits its level value - <varname>DEBUG</varname> from its parent <varname>X</varname>. - </para> - <table> - <title>Level Inheritance - Example 4</title> + <para>In example 3, the loggers <varname>root</varname>, + <varname>X</varname> and <varname>X.Y.Z</varname> are assigned + the levels <varname>INFO</varname>, <varname>DEBUG</varname> + and <varname>WARN</varname> respectively. The logger + <varname>X.Y</varname> inherits its level value + <varname>DEBUG</varname> from its parent <varname>X</varname>. + </para> + + <table> + <title>Level Inheritance - Example 4</title> <tgroup cols="3"> - <thead> - <row> - <entry>Logger name</entry> + <thead> + <row> + <entry>Logger name</entry> <entry>Assigned level</entry> - <entry>Effective level</entry> - </row> - </thead> - - <tbody> + <entry>Effective level</entry> + </row> + </thead> - <row><entry>root</entry> - <entry>DEBUG</entry> <entry>DEBUG</entry> - </row> - <row> - <entry>X </entry> - <entry>ERROR</entry> - <entry>ERROR</entry> - </row> - <row> - <entry>X.Y </entry> - <entry>none</entry> - <entry>ERROR</entry> - </row> - <row> - <entry>X.Y.Z</entry> - <entry>none</entry> - <entry>ERROR</entry></row> - </tbody> - </tgroup> - </table> - - <para>In example 4, the loggers <varname>root</varname> and + <tbody> + + <row><entry>root</entry> + <entry>DEBUG</entry> <entry>DEBUG</entry> + </row> + <row> + <entry>X </entry> + <entry>ERROR</entry> + <entry>ERROR</entry> + </row> + <row> + <entry>X.Y </entry> + <entry>none</entry> + <entry>ERROR</entry> + </row> + <row> + <entry>X.Y.Z</entry> + <entry>none</entry> + <entry>ERROR</entry></row> + </tbody> + </tgroup> + </table> + + <para>In example 4, the loggers <varname>root</varname> and <varname>X</varname> and are assigned the levels <varname>Proot</varname> and <varname>DEBUG</varname> respectively. The loggers <varname>X.Y</varname> and - <varname>X.Y.Z</varname> inherits their level (ERROR) from - their nearest parent <varname>X</varname> with an assigned - level. - </para> - - <para>Logging requests are made by invoking one of the - printing methods of a logger instance. These printing - methods are - - <ulink url="../api/org/apache/log4j/Category.html#debug(java.lang.Object)">debug</ulink>, - - <ulink url="../api/org/apache/log4j/Category.html#info(java.lang.Object)">info</ulink>, - - <ulink - url="../api/org/apache/log4j/Category.html#warn(java.lang.Object)">warn</ulink>, - <ulink - url="../api/org/apache/log4j/Category.html#error(java.lang.Object)">error</ulink>, - <ulink - url="../api/org/apache/log4j/Category.html#fatal(java.lang.Object)">fatal</ulink> - and <ulink - url="../api/org/apache/log4j/Category.html#log(org.apache.log4j.Priority, java.lang.Object)">log</ulink>. + <varname>X.Y.Z</varname> inherits their level (ERROR) from their + nearest parent <varname>X</varname> with an assigned level. </para> + <para>Logging requests are made by invoking one of the printing + methods of a logger instance. These printing methods are + + <ulink url="../api/org/apache/log4j/Category.html#debug(java.lang.Object)">debug</ulink>, + + <ulink url="../api/org/apache/log4j/Category.html#info(java.lang.Object)">info</ulink>, + + <ulink + url="../api/org/apache/log4j/Category.html#warn(java.lang.Object)">warn</ulink>, + <ulink + url="../api/org/apache/log4j/Category.html#error(java.lang.Object)">error</ulink>, + <ulink + url="../api/org/apache/log4j/Category.html#fatal(java.lang.Object)">fatal</ulink> + and <ulink + url="../api/org/apache/log4j/Category.html#log(org.apache.log4j.Priority, java.lang.Object)">log</ulink>. + </para> + + </sect2> + <sect2 id="basicSelectionRule" xreflabel="Basic Selection Rule"> <title>Basic Selection rule</title> <para>By definition, the printing method determines the level of a logging request. For example, if <varname>x</varname> is a - logger instance, then the statement - <function>x.info("..")</function> is a logging request of - level <emphasis>info</emphasis>. + logger instance, then the statement <function>x.info("Hello + world.")</function> is a logging request of level + <emphasis>info</emphasis>. </para> <para>A logging request is said to be <emphasis>enabled</emphasis> @@ -409,8 +486,8 @@ // get a logger instance named "com.foo" Logger cat = Logger.getLogger("com.foo"); - // Now set its level. Normally you do not need to set the // level - of a logger programatically but rather in a configuration script. + // Now set its level. Normally you do not need to set the + // level of a logger programatically but rather in a configuration script. cat.setLevel(Level.INFO); Logger barcat = Logger.getLogger("com.foo.Bar"); @@ -443,19 +520,29 @@ <para>One can set a respository-wide threshold such that a request below the threshold level is dropped regardless of the - logger or its effective level. For example, If you choose set + logger or its effective level. The repository-wide threshold + can be viewed as a central switch that can turn logging on or + off for the entire hierarchy. For example, If you choose set the respository-wide threshold to the <varname>info</varname> level, then you have effectively disabled logging below the - info level such that the <varname>debug</varname> level - requests will be dropped regardless of the logger settings. + info level such that all <varname>debug</varname> level + requests will be dropped regardless of logger and its + configuration. </para> - <para>The repository-wide threshold acts as a filter which is - applied prior to the <xref + <para>The repository-wide threshold is as a filter which is + applied <emphasis>prior</emphasis> to the <xref linkend="basicSelectionRule"/>. This has important performance - implication which is futher discussed in <xref linkend="performance"/>. + implication which is futher discussed in <xref + linkend="performance"/>. By default, the repository-wide + level is set to the <varname>ALL</varname> level which is the + lowest possible level. Thus, the repository-wide threshold + does not filter out any requests letting the basic selection + rule to apply. </para> + <para>Here is an example.</para> + <programlisting> // get a logger with the name "foo.bar" Logger x = Logger.gerInstance("foo.bar"); @@ -492,69 +579,11 @@ <note> <para>Normally, you do not need to set the repository-wide - level nor the level of the loggers contained therein - programatically. Repositoreies and loggers are configured - using configuration scripts. This method is discussed in - chapter <xref linkend="configuration"/>. + threshold programatically. Repositoreies and loggers are + configured using configuration scripts. This method is + discussed in chapter <xref linkend="configuration"/>. </para> </note> - - <para>By default, the repository-wide level is set to - <varname>Level.ALL</varname> such that all requests are - evaluated by the basic selection rule. - </para> - </sect2> - - - <sect2> - <title>Once only creation</title> - - <para>Calling the <varname>getLogger</varname> method - with the same name will always return a reference to - the exact same logger object. - </para> - - <para>For example, in</para> - - <para><programlisting> - Logger x = Logger.getLogger("wombat"); - Logger y = Logger.getLogger("wombat");</programlisting></para> - - <para> - <varname>x</varname> and <varname>y</varname> refer to - <emphasis>exactly</emphasis> the same logger object. - </para> - - <para>Thus, it is possible to configure a logger and then to - retrieve the same instance somewhere else in the code without - passing around references. In contrast to biological parenthood, - where parents always preceed their children, log4j loggers can - be created and configured in any order. In particular, a - "parent" logger will find and link to its descendants even if it - is instantiated after them. - </para> - - <para>Configuration of the log4j environment is typically done - at application initialization. The preferred way is by reading - a configuration file. This approach will be discussed in <xref - linkend="configuration"/>. - </para> - - <para>Log4j makes it easy to name loggers by <emphasis>software - component</emphasis>. This can be accomplished by statically - instantiating a logger in each class, with the logger name - equal to the fully qualified name of the class. This is a - useful and straightforward method of defining loggers. As the - log output bears the name of the generating logger, this - naming strategy makes it easy to identify the origin of a log - message. However, this is only one possible, albeit common, - strategy for naming loggers. Log4j does not impose any - restriction on the name of loggers. The user is free to name - logger as she wishes. - </para> - - <para>Nevertheless, naming loggers after the class where they - are located seems to be the best strategy known so far.</para> </sect2> </sect1> 1.13 +15 -13 jakarta-log4j/src/docbook/configuration.xml Index: configuration.xml =================================================================== RCS file: /home/cvs/jakarta-log4j/src/docbook/configuration.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- configuration.xml 2001/10/12 07:05:11 1.12 +++ configuration.xml 2001/11/14 20:31:14 1.13 @@ -1,6 +1,6 @@ <chapter id="configuration"> <title>Configuration</title> - + <para> disabling from configuration files, duplicates in log @@ -197,7 +197,7 @@ </sect1> <sect1> - <title>DOMConfigurator equivalent</title> + <title><classname>DOMConfigurator</classname> equivalent</title> <para>As mention previously, log4j also supports configuration files written in XML. These configuration files are parsed with @@ -241,7 +241,7 @@ &lt;appender name="STDOUT" class="org.apache.log4j.ConsoleAppender"> &lt;layout class="org.apache.log4j.PatternLayout"> &lt;param name="ConversionPattern" - value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/> + value="=%-4r [%t] %-5p %c %x - %m%n"/> &lt;/layout> &lt;/appender> @@ -261,22 +261,24 @@ </sect1> <sect1> - <title>PropertyConfigurator: Filtering by request level</title> + <title><classname>PropertyConfigurator</classname>: Filtering by + logger and request level</title> <para>As was mentioned earlier, one the important features of any logging library is its support for filtering logging messages depending on various criteria. In a very common scenario, the - user will want to filter out requests depending on the request - level and software component. In <xref - linkend="thresholdFiltering"/> and <xref - linkend="configuringFilters"/> and we discuss more general but - less efficient ways of filtering. + user will want to filter out requests depending on the logger + and the request level. Note that if you name loggers by class + name then filtering by logger is equivalent to filtering by + class name which is usually closely related to the software + component. In the following sections we will discuss more + general but less efficient ways of filtering. </para> <para>Suppose we are no longer interested in seeing any INFO or DEBUG level logs from any component belonging to the <classname>com.foo</classname> package. The following - configuration file shows one efficient way of specifying this. + configuration file shows one efficient way of achieving this. </para> <para> @@ -326,7 +328,7 @@ &lt;appender name="STDOUT" class="org.apache.log4j.ConsoleAppender"> &lt;layout class="org.apache.log4j.PatternLayout"> &lt;param name="ConversionPattern" - value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/> + value="[%t] %-5p %c - %m%n"/> &lt;/layout> &lt;/appender> @@ -348,7 +350,7 @@ <sect1> - <title>Multiple appenders</title> + <title>Multiple appenders (<classname>PropertyConfigurator</classname>)</title> <para>Here is another configuration file that uses multiple appenders.</para> @@ -404,7 +406,7 @@ </sect1> <sect1> - <title>Multiple Appenders using <classname>DOMConfigurator</classname></title> + <title>Multiple Appenders (<classname>DOMConfigurator</classname>)</title> <para> <example><title>XML equivalent configuration file</title> <screen> 1.8 +1 -0 jakarta-log4j/src/java/org/apache/log4j/varia/Makefile Index: Makefile =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/varia/Makefile,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Makefile 2001/09/02 20:05:40 1.7 +++ Makefile 2001/11/14 20:31:15 1.8 @@ -8,6 +8,7 @@ LevelMatchFilter.java\ PriorityRangeFilter.java\ PriorityMatchFilter.java\ + ReloadingPropertyConfigurator.java\ SUBDIRS :=test 1.9 +1 -1 jakarta-log4j/src/java/org/apache/log4j/varia/PriorityMatchFilter.java Index: PriorityMatchFilter.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/varia/PriorityMatchFilter.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- PriorityMatchFilter.java 2001/09/02 20:05:40 1.8 +++ PriorityMatchFilter.java 2001/11/14 20:31:15 1.9 @@ -3,7 +3,7 @@ * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.APL file. + * the LICENSE.txt file. */ package org.apache.log4j.varia; 1.1 jakarta-log4j/src/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java Index: ReloadingPropertyConfigurator.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.log4j.varia; import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.spi.Configurator; import java.net.URL; import org.apache.log4j.spi.LoggerRepository; public class ReloadingPropertyConfigurator implements Configurator { PropertyConfigurator delegate = new PropertyConfigurator(); public ReloadingPropertyConfigurator() { } public void doConfigure(URL url, LoggerRepository repository) { } } -- To unsubscribe, e-mail: <mailto:larryaguilar@example.net> For additional commands, e-mail: <mailto:larryaguilar@example.net> From log4j-cvslarryaguilar@example.net Thu Nov 15 11:09:02 2001 Return-Path: <log4j-cvslarryaguilar@example.net> Delivered-To: larryaguilar@example.net Received: (qmail 75344 invoked from network); 15 Nov 2001 11:09:01 -0000 Received: from unknown (HELO nagoya.betaversion.org) (83.161.120.155) by daedalus.apache.org with SMTP; 15 Nov 2001 11:09:01 -0000 Received: (qmail 18047 invoked by uid 97); 15 Nov 2001 11:09:15 -0000 Delivered-To: larryaguilar@example.net Received: (qmail 18006 invoked by uid 97); 15 Nov 2001 11:09:14 -0000 Mailing-List: contact larryaguilar@example.net; run by ezmlm Precedence: bulk List-Unsubscribe: <mailto:larryaguilar@example.net> List-Subscribe: <mailto:larryaguilar@example.net> List-Help: <mailto:larryaguilar@example.net> List-Post: <mailto:larryaguilar@example.net> List-Id: "Log4J CVS List" <log4j-cvs.jakarta.apache.org> Reply-To: "Log4J Developers List" <larryaguilar@example.net> Delivered-To: mailing list larryaguilar@example.net Received: (qmail 17995 invoked from network); 15 Nov 2001 11:09:12 -0000 Date: 15 Nov 2001 10:55:36 -0000 Message-ID: <larryaguilar@example.net> From: larryaguilar@example.net To: larryaguilar@example.net Subject: cvs commit: jakarta-log4j build.sh X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ceki 01/11/15 02:55:35 Modified: . build.sh Log: Small test Revision Changes Path 1.7 +1 -1 jakarta-log4j/build.sh Index: build.sh =================================================================== RCS file: /home/cvs/jakarta-log4j/build.sh,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- build.sh 2001/10/17 06:37:29 1.6 +++ build.sh 2001/11/15 10:55:35 1.7 @@ -1,5 +1,5 @@ #!/bin/sh - + #-------------------------------------------- # No need to edit anything past here #-------------------------------------------- -- To unsubscribe, e-mail: <mailto:larryaguilar@example.net> For additional commands, e-mail: <mailto:larryaguilar@example.net> From log4j-cvslarryaguilar@example.net Fri Nov 16 12:02:50 2001 Return-Path: <log4j-cvslarryaguilar@example.net> Delivered-To: larryaguilar@example.net Received: (qmail 55790 invoked from network); 16 Nov 2001 12:02:50 -0000 Received: from unknown (HELO nagoya.betaversion.org) (83.161.120.155) by daedalus.apache.org with SMTP; 16 Nov 2001 12:02:50 -0000 Received: (qmail 4806 invoked by uid 97); 16 Nov 2001 12:02:50 -0000 Delivered-To: larryaguilar@example.net Received: (qmail 4770 invoked by uid 97); 16 Nov 2001 12:02:49 -0000 Mailing-List: contact larryaguilar@example.net; run by ezmlm Precedence: bulk List-Unsubscribe: <mailto:larryaguilar@example.net> List-Subscribe: <mailto:larryaguilar@example.net> List-Help: <mailto:larryaguilar@example.net> List-Post: <mailto:larryaguilar@example.net> List-Id: "Log4J CVS List" <log4j-cvs.jakarta.apache.org> Reply-To: "Log4J Developers List" <larryaguilar@example.net> Delivered-To: mailing list larryaguilar@example.net Received: (qmail 4749 invoked from network); 16 Nov 2001 12:02:48 -0000 Date: 16 Nov 2001 11:48:55 -0000 Message-ID: <larryaguilar@example.net> From: larryaguilar@example.net To: larryaguilar@example.net Subject: cvs commit: jakarta-log4j/src/java/org/apache/log4j/config PropertySetter.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ceki 01/11/16 03:48:55 Modified: src/java/org/apache/log4j/config PropertySetter.java Log: Slightly better way of getting the keys in a Propperties object. Submitted by: Georg Lundesgaard Reviewed by: Ceki Gulcu Revision Changes Path 1.10 +1 -1 jakarta-log4j/src/java/org/apache/log4j/config/PropertySetter.java Index: PropertySetter.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/config/PropertySetter.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- PropertySetter.java 2001/09/05 06:45:28 1.9 +++ PropertySetter.java 2001/11/16 11:48:55 1.10 @@ -98,7 +98,7 @@ void setProperties(Properties properties, String prefix) { int len = prefix.length(); - for (Enumeration e = properties.keys(); e.hasMoreElements(); ) { + for (Enumeration e = properties.propertyNames(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); // handle only properties that start with the desired frefix. -- To unsubscribe, e-mail: <mailto:larryaguilar@example.net> For additional commands, e-mail: <mailto:larryaguilar@example.net> From log4j-cvslarryaguilar@example.net Fri Nov 16 12:32:10 2001 Return-Path: <log4j-cvslarryaguilar@example.net> Delivered-To: larryaguilar@example.net Received: (qmail 69720 invoked from network); 16 Nov 2001 12:32:10 -0000 Received: from unknown (HELO nagoya.betaversion.org) (83.161.120.155) by daedalus.apache.org with SMTP; 16 Nov 2001 12:32:10 -0000 Received: (qmail 5065 invoked by uid 97); 16 Nov 2001 12:32:09 -0000 Delivered-To: larryaguilar@example.net Received: (qmail 5049 invoked by uid 97); 16 Nov 2001 12:32:08 -0000 Mailing-List: contact larryaguilar@example.net; run by ezmlm Precedence: bulk List-Unsubscribe: <mailto:larryaguilar@example.net> List-Subscribe: <mailto:larryaguilar@example.net> List-Help: <mailto:larryaguilar@example.net> List-Post: <mailto:larryaguilar@example.net> List-Id: "Log4J CVS List" <log4j-cvs.jakarta.apache.org> Reply-To: "Log4J Developers List" <larryaguilar@example.net> Delivered-To: mailing list larryaguilar@example.net Received: (qmail 5038 invoked from network); 16 Nov 2001 12:32:08 -0000 Date: 16 Nov 2001 12:18:16 -0000 Message-ID: <larryaguilar@example.net> From: larryaguilar@example.net To: larryaguilar@example.net Subject: cvs commit: jakarta-log4j/src/java/org/apache/log4j/config PropertySetter.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ceki 01/11/16 04:18:16 Modified: src/java/org/apache/log4j/config PropertySetter.java Log: Just added Georg Lundesgaard as a contributor. Revision Changes Path 1.11 +2 -0 jakarta-log4j/src/java/org/apache/log4j/config/PropertySetter.java Index: PropertySetter.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/config/PropertySetter.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- PropertySetter.java 2001/11/16 11:48:55 1.10 +++ PropertySetter.java 2001/11/16 12:18:15 1.11 @@ -6,6 +6,8 @@ * the LICENSE.APL file. */ +// Contributors: Georg Lundesgaard + package org.apache.log4j.config; import java.beans.Introspector; -- To unsubscribe, e-mail: <mailto:larryaguilar@example.net> For additional commands, e-mail: <mailto:larryaguilar@example.net> From log4j-cvslarryaguilar@example.net Fri Nov 16 14:33:37 2001 Return-Path: <log4j-cvslarryaguilar@example.net> Delivered-To: larryaguilar@example.net Received: (qmail 36074 invoked from network); 16 Nov 2001 14:33:36 -0000 Received: from unknown (HELO nagoya.betaversion.org) (83.161.120.155) by daedalus.apache.org with SMTP; 16 Nov 2001 14:33:36 -0000 Received: (qmail 20978 invoked by uid 97); 16 Nov 2001 14:33:07 -0000 Delivered-To: larryaguilar@example.net Received: (qmail 20890 invoked by uid 97); 16 Nov 2001 14:33:06 -0000 Mailing-List: contact larryaguilar@example.net; run by ezmlm Precedence: bulk List-Unsubscribe: <mailto:larryaguilar@example.net> List-Subscribe: <mailto:larryaguilar@example.net> List-Help: <mailto:larryaguilar@example.net> List-Post: <mailto:larryaguilar@example.net> List-Id: "Log4J CVS List" <log4j-cvs.jakarta.apache.org> Reply-To: "Log4J Developers List" <larryaguilar@example.net> Delivered-To: mailing list larryaguilar@example.net Received: (qmail 20793 invoked from network); 16 Nov 2001 14:33:04 -0000 Date: 16 Nov 2001 14:19:09 -0000 Message-ID: <larryaguilar@example.net> From: larryaguilar@example.net To: larryaguilar@example.net Subject: cvs commit: jakarta-log4j build.xml X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ceki 01/11/16 06:19:09 Added: . build.xml Log: The build.xml file is in the topmost project directory in most jakarta projects. Just following the crowd. Will also soon remove the build.sh and build.bat files like other jakarta projects. Revision Changes Path 1.8 +366 -11 jakarta-log4j/build.xml -- To unsubscribe, e-mail: <mailto:larryaguilar@example.net> For additional commands, e-mail: <mailto:larryaguilar@example.net> From log4j-cvslarryaguilar@example.net Sat Nov 17 01:18:20 2001 Return-Path: <log4j-cvslarryaguilar@example.net> Delivered-To: larryaguilar@example.net Received: (qmail 49244 invoked from network); 17 Nov 2001 01:18:19 -0000 Received: from unknown (HELO nagoya.betaversion.org) (83.161.120.155) by daedalus.apache.org with SMTP; 17 Nov 2001 01:18:19 -0000 Received: (qmail 26686 invoked by uid 97); 17 Nov 2001 01:18:27 -0000 Delivered-To: larryaguilar@example.net Received: (qmail 26643 invoked by uid 97); 17 Nov 2001 01:18:25 -0000 Mailing-List: contact larryaguilar@example.net; run by ezmlm Precedence: bulk List-Unsubscribe: <mailto:larryaguilar@example.net> List-Subscribe: <mailto:larryaguilar@example.net> List-Help: <mailto:larryaguilar@example.net> List-Post: <mailto:larryaguilar@example.net> List-Id: "Log4J CVS List" <log4j-cvs.jakarta.apache.org> Reply-To: "Log4J Developers List" <larryaguilar@example.net> Delivered-To: mailing list larryaguilar@example.net Received: (qmail 26630 invoked from network); 17 Nov 2001 01:18:24 -0000 Date: 17 Nov 2001 01:04:22 -0000 Message-ID: <larryaguilar@example.net> From: larryaguilar@example.net To: larryaguilar@example.net Subject: cvs commit: jakarta-log4j/src/java/org/apache/log4j/xml DOMConfigurator.java log4j.dtd X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ceki 01/11/16 17:04:22 Modified: src/java/org/apache/log4j AsyncAppender.java Category.java FileAppender.java LogManager.java Logger.java WriterAppender.java src/java/org/apache/log4j/helpers AppenderAttachableImpl.java OnlyOnceErrorHandler.java src/java/org/apache/log4j/spi AppenderAttachable.java ErrorHandler.java src/java/org/apache/log4j/test Shallow.java src/java/org/apache/log4j/test/xml domTest4.xml src/java/org/apache/log4j/varia Makefile src/java/org/apache/log4j/xml DOMConfigurator.java log4j.dtd Added: src/java/org/apache/log4j/test/xml fallback1.xml src/java/org/apache/log4j/varia FallbackErrorHandler.java Log: First incomplete implementation of FallbackErrorHandler. This required some changes to the ErrorHandler interface. Revision Changes Path 1.24 +8 -0 jakarta-log4j/src/java/org/apache/log4j/AsyncAppender.java Index: AsyncAppender.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/AsyncAppender.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- AsyncAppender.java 2001/08/14 21:00:34 1.23 +++ AsyncAppender.java 2001/11/17 01:04:21 1.24 @@ -188,6 +188,14 @@ return locationInfo; } + /** + Is the appender passed as parameter attached to this category? + */ + public + boolean isAttached(Appender appender) { + return aai.isAttached(appender); + } + /** The <code>AsyncAppender</code> does not require a layout. Hence, 1.54 +11 -0 jakarta-log4j/src/java/org/apache/log4j/Category.java Index: Category.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/Category.java,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- Category.java 2001/09/21 15:49:43 1.53 +++ Category.java 2001/11/17 01:04:21 1.54 @@ -714,6 +714,17 @@ } /** + Is the appender passed as parameter attached to this category? + */ + public + boolean isAttached(Appender appender) { + if(appender == null || aai == null) + return false; + else + return aai.isAttached(appender); + } + + /** * Check whether this category is enabled for the <code>DEBUG</code> * Level. * 1.31 +1 -1 jakarta-log4j/src/java/org/apache/log4j/FileAppender.java Index: FileAppender.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/FileAppender.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- FileAppender.java 2001/11/06 23:04:51 1.30 +++ FileAppender.java 2001/11/17 01:04:21 1.31 @@ -21,9 +21,9 @@ import org.apache.log4j.helpers.OptionConverter; import org.apache.log4j.helpers.QuietWriter; import org.apache.log4j.helpers.LogLog; -//import org.apache.log4j.helpers.TracerPrintWriter; // Contibutors: Jens Uwe Pipka <larryaguilar@example.net> +// Ben Sandee /** FileAppender appends log events to a file. 1.6 +3 -3 jakarta-log4j/src/java/org/apache/log4j/LogManager.java Index: LogManager.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/LogManager.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- LogManager.java 2001/09/28 13:37:48 1.5 +++ LogManager.java 2001/11/17 01:04:21 1.6 @@ -207,7 +207,7 @@ public static Logger getLogger(String name) { - // Delegate the actual manufacturing of the logger to the logger factory. + // Delegate the actual manufacturing of the logger to the logger repository. return repositorySelector.getLoggerRepository().getLogger(name); } @@ -217,7 +217,7 @@ public static Logger getLogger(Class clazz) { - // Delegate the actual manufacturing of the logger to the logger factory. + // Delegate the actual manufacturing of the logger to the logger repository. return repositorySelector.getLoggerRepository().getLogger(clazz.getName()); } @@ -228,7 +228,7 @@ public static Logger getLogger(String name, LoggerFactory factory) { - // Delegate the actual manufacturing of the logger to the logger factory. + // Delegate the actual manufacturing of the logger to the logger repository. return repositorySelector.getLoggerRepository().getLogger(name, factory); } 1.8 +0 -2 jakarta-log4j/src/java/org/apache/log4j/Logger.java Index: Logger.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/Logger.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Logger.java 2001/10/22 23:08:59 1.7 +++ Logger.java 2001/11/17 01:04:21 1.8 @@ -122,6 +122,4 @@ Logger getRootLogger() { return LogManager.getRootLogger(); } - - } 1.19 +1 -0 jakarta-log4j/src/java/org/apache/log4j/WriterAppender.java Index: WriterAppender.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/WriterAppender.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- WriterAppender.java 2001/11/06 23:04:51 1.18 +++ WriterAppender.java 2001/11/17 01:04:21 1.19 @@ -21,6 +21,7 @@ import org.apache.log4j.helpers.LogLog; // Contibutors: Jens Uwe Pipka <larryaguilar@example.net> +// Ben Sandee /** WriterAppender appends log events to a {@link java.io.Writer} or an 1.6 +23 -0 jakarta-log4j/src/java/org/apache/log4j/helpers/AppenderAttachableImpl.java Index: AppenderAttachableImpl.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/helpers/AppenderAttachableImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- AppenderAttachableImpl.java 2001/07/05 19:09:34 1.5 +++ AppenderAttachableImpl.java 2001/11/17 01:04:22 1.6 @@ -97,6 +97,29 @@ return null; } + + /** + Returns <code>true</code> if the specified appender is in the + list of attached appenders, <code>false</code> otherwise. + + @since 1.2 */ + public + boolean isAttached(Appender appender) { + if(appenderList == null || appender == null) + return false; + + int size = appenderList.size(); + Appender a; + for(int i = 0; i < size; i++) { + a = (Appender) appenderList.elementAt(i); + if(a == appender) + return true; + } + return false; + } + + + /** Remove all previously attached appenders. */ 1.8 +33 -42 jakarta-log4j/src/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java Index: OnlyOnceErrorHandler.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- OnlyOnceErrorHandler.java 2001/07/05 19:09:43 1.7 +++ OnlyOnceErrorHandler.java 2001/11/17 01:04:22 1.8 @@ -9,6 +9,9 @@ package org.apache.log4j.helpers; import org.apache.log4j.spi.ErrorHandler; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.log4j.Logger; +import org.apache.log4j.Appender; /** @@ -31,32 +34,19 @@ boolean firstTime = true; - /** - Returns <code>null</code> as <code>OnlyOnceErrorHandler</code> - has no options. - - @deprecated We now use JavaBeans introspection to configure - components. Options strings are no longer needed. - */ - public - String[] getOptionStrings() { - return null; - } /** - No options to set. - - @deprecated Use the setter method for the option directly instead - of the generic <code>setOption</code> method. - */ - public - void setOption(String key, String value) { + Does not do anything. + */ + public + void setLogger(String loggerName) { } + /** No options to activate. */ - public + public void activateOptions() { } @@ -66,44 +56,45 @@ <code>System.err</code>. */ public void error(String message, Exception e, int errorCode) { - if(firstTime) { - LogLog.error(message, e); - firstTime = false; - } + error(message, e, errorCode, null); } - /** - Returns <code>null</code> as <code>OnlyOnceErrorHandler</code> - has no options. - public - String[] getOptionStrings() { - return null; - }*/ - /** - No options to set. + Prints the message and the stack trace of the exception on + <code>System.err</code>. + */ public - void setOption(String key, String value) { + void error(String message, Exception e, int errorCode, LoggingEvent event) { + if(firstTime) { + LogLog.error(message, e); + firstTime = false; + } } - */ - /** - No options to get. - public - String getOption(String key) { - return null; - } - */ /** Print a the error message passed as parameter on <code>System.err</code>. */ - public + public void error(String message) { if(firstTime) { LogLog.error(message); firstTime = false; } + } + + /** + Does not do anything. + */ + public + void setAppender(Appender appender) { + } + + /** + Does not do anything. + */ + public + void setBackupAppender(Appender appender) { } } 1.5 +9 -0 jakarta-log4j/src/java/org/apache/log4j/spi/AppenderAttachable.java Index: AppenderAttachable.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/AppenderAttachable.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AppenderAttachable.java 2001/07/05 19:07:16 1.4 +++ AppenderAttachable.java 2001/11/17 01:04:22 1.5 @@ -34,6 +34,15 @@ public Appender getAppender(String name); + + /** + Returns <code>true</code> if the specified appender is in list of + attached attached, <code>false</code> otherwise. + + @since 1.2 */ + public + boolean isAttached(Appender appender); + /** Remove all previously added appenders. */ 1.4 +46 -10 jakarta-log4j/src/java/org/apache/log4j/spi/ErrorHandler.java Index: ErrorHandler.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/ErrorHandler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ErrorHandler.java 2001/07/05 19:07:18 1.3 +++ ErrorHandler.java 2001/11/17 01:04:22 1.4 @@ -8,9 +8,12 @@ package org.apache.log4j.spi; import org.apache.log4j.Appender; +import org.apache.log4j.Logger; + /** - Appenders may delegate their error handling to ErrorHandlers. + Appenders may delegate their error handling to + <code>ErrorHandlers</code>. <p>Error handling is a particularly tedious to get right because by definition errors are hard to predict and to reproduce. @@ -22,25 +25,58 @@ @author Ceki G&uuml;lc&uuml; - - @since 0.9.0 */ + +*/ public interface ErrorHandler extends OptionHandler { + /** + Add a reference to a logger to which the failing appender might + be attached to. The failing appender will be searched and + replaced only in the loggers you add through this method. + + @param loggerName The name of the logger that will be searched + for the failing appender in view of replacement. + + @since 1.2 */ + void setLogger(Stiring loggerName); + /** - This method should handle the error. Information about the error - condition is passed a parameter. + Equivalent to the {@link #error(String, Exception, int, + LoggingEvent event)} with the the event parameteter set to + <code>null</code>. - @param message The message assoicated with the error. - @param e The Exption that was thrown when the error occured. - @param errorCode The error code associated with the error. */ void error(String message, Exception e, int errorCode); - /** - This method prints the error message passed as a parameter. + This method is normally used to just print the error message + passed as a parameter. */ void error(String message); + /** + This method is invoked to handle the error. + + @param message The message assoicated with the error. + @param e The Exption that was thrown when the error occured. + @param errorCode The error code associated with the error. + @param event The logging event that the failing appender is asked + to log. + + @since 1.2 */ + void error(String message, Exception e, int errorCode, LoggingEvent event); + + /** + Set the appender for which errors are handled. This method is + usually called when the error handler is configured. + + @since 1.2 */ + void setAppender(Appender appender); + + /** + Set the appender to falkback upon in case of failure. + + @since 1.2 */ + void setBackupAppender(Appender appender); } 1.7 +1 -1 jakarta-log4j/src/java/org/apache/log4j/test/Shallow.java Index: Shallow.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/test/Shallow.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Shallow.java 2001/09/04 14:53:13 1.6 +++ Shallow.java 2001/11/17 01:04:22 1.7 @@ -2,7 +2,7 @@ * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.APL file. + * the LICENSE.txt file. */ // NOTICE: Some tests are sensitive to line numbers! package org.apache.log4j.test; 1.3 +2 -2 jakarta-log4j/src/java/org/apache/log4j/test/xml/domTest4.xml Index: domTest4.xml =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/test/xml/domTest4.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- domTest4.xml 2001/10/12 07:05:12 1.2 +++ domTest4.xml 2001/11/17 01:04:22 1.3 @@ -14,8 +14,8 @@ <category name="org.apache.log4j.xml"> <priority value="inherited"/> </category> - <rot> + <root> <priority value="error"/> <appender-ref ref="A1" /> - </rot> + </root> </log4j:configuration> 1.1 jakarta-log4j/src/java/org/apache/log4j/test/xml/fallback1.xml Index: fallback1.xml =================================================================== <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="PRIMARY" class="org.apache.log4j.FileAppender"> <errorHandler class="org.apache.log4j.varia.FallbackErrorHandler"> <param name="logger" value="root"/> <appender-ref ref="FALLBACK" /> </errorHandler> <param name="File" value="/xyz/x.log" /> <param name="Append" value="false" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%-5p %c{2} - %m\n"/> </layout> </appender> <appender name="FALLBACK" class="org.apache.log4j.FileAppender"> <param name="File" value="temp.A2" /> <param name="Append" value="false" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="FALLBACK - %c - %m\n"/> </layout> </appender> <root> <priority value ="debug" /> <appender-ref ref="PRIMARY" /> </root> </log4j:configuration> 1.9 +1 -0 jakarta-log4j/src/java/org/apache/log4j/varia/Makefile Index: Makefile =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/varia/Makefile,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- Makefile 2001/11/14 20:31:15 1.8 +++ Makefile 2001/11/17 01:04:22 1.9 @@ -9,6 +9,7 @@ PriorityRangeFilter.java\ PriorityMatchFilter.java\ ReloadingPropertyConfigurator.java\ + FallbackErrorHandler.java\ SUBDIRS :=test 1.1 jakarta-log4j/src/java/org/apache/log4j/varia/FallbackErrorHandler.java Index: FallbackErrorHandler.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.log4j.varia; import org.apache.log4j.spi.ErrorHandler; import org.apache.log4j.spi.LoggingEvent; import org.apache.log4j.Appender; import org.apache.log4j.Logger; import java.util.Vector; /** The <code>FallbackErrorHandler</code> implements the ErrorHandler interface such that a secondary appender may be specified. This secondary appender takes over if the primary appender fails for whatever reason. <p>The error message is printed on <code>System.err</code>, and logged in the new secondary appender. */ public class FallbackErrorHandler implements ErrorHandler { Appender backup; Appender primary; Vector loggers; public FallbackErrorHandler() { } /** <em>Adds</em> the logger passed as parameter to the list of loggers that we need to search for in case of appender failure. */ public void setLogger(String loggerName) { if(loggers == null) { loggers = new Vector(); } if(loggerName.equalsIgnoreCase loggers.add(logger); } /** No options to activate. */ public void activateOptions() { } /** Prints the message and the stack trace of the exception on <code>System.err</code>. */ public void error(String message, Exception e, int errorCode) { error(message, e, errorCode, null); } /** Prints the message and the stack trace of the exception on <code>System.err</code>. */ public void error(String message, Exception e, int errorCode, LoggingEvent event) { for(int i = 0; i < loggers.size(); i++) { Logger l = (Logger) loggers.get(i); if(l.isAttached(primary)) { l.removeAppender(primary); l.addAppender(backup); } } } /** Print a the error message passed as parameter on <code>System.err</code>. */ public void error(String message) { //if(firstTime) { //LogLog.error(message); //firstTime = false; //} } /** The appender to which this error handler is attached. */ public void setAppender(Appender primary) { this.primary = primary; } /** Set the backup appender. */ public void setBackupAppender(Appender backup) { this.backup = backup; } } 1.39 +19 -9 jakarta-log4j/src/java/org/apache/log4j/xml/DOMConfigurator.java Index: DOMConfigurator.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/DOMConfigurator.java,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- DOMConfigurator.java 2001/10/04 21:07:04 1.38 +++ DOMConfigurator.java 2001/11/17 01:04:22 1.39 @@ -104,25 +104,22 @@ } /** - Used internally to parse appenders by IDREF. - */ + Used internally to parse appenders by IDREF name. + */ protected - Appender findAppenderByReference(Element appenderRef) { - String appenderName = subst(appenderRef.getAttribute(REF_ATTR)); - + Appender findAppenderByName(Document doc, String appenderName) { Appender appender = (Appender) appenderBag.get(appenderName); + if(appender != null) { return appender; } else { - Document doc = appenderRef.getOwnerDocument(); - // Doesn't work on DOM Level 1 : // Element element = doc.getElementById(appenderName); // Endre's hack: Element element = null; NodeList list = doc.getElementsByTagName("appender"); - for (int t=0; t<list.getLength(); t++) { + for (int t=0; t < list.getLength(); t++) { Node node = list.item(t); NamedNodeMap map= node.getAttributes(); Node attrNode = map.getNamedItem("name"); @@ -143,6 +140,15 @@ } } } + /** + Used internally to parse appenders by IDREF element. + */ + protected + Appender findAppenderByReference(Element appenderRef) { + String appenderName = subst(appenderRef.getAttribute(REF_ATTR)); + Document doc = appenderRef.getOwnerDocument(); + return findAppenderByName(doc, appenderName); + } /** Used internally to parse an appender element. @@ -221,6 +227,8 @@ null); if(eh != null) { + eh.setAppender(appender); + PropertySetter propSetter = new PropertySetter(eh); NodeList children = element.getChildNodes(); final int length = children.getLength(); @@ -232,6 +240,8 @@ String tagName = currentElement.getTagName(); if(tagName.equals(PARAM_TAG)) { setParameter(currentElement, propSetter); + } else if(tagName.equals(APPENDER_REF_TAG)) { + eh.setBackupAppender(findAppenderByReference(currentElement)); } } } @@ -261,7 +271,7 @@ String tagName = currentElement.getTagName(); if(tagName.equals(PARAM_TAG)) { setParameter(currentElement, propSetter); - } + } } } propSetter.activate(); 1.13 +3 -1 jakarta-log4j/src/java/org/apache/log4j/xml/log4j.dtd Index: log4j.dtd =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/log4j.dtd,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- log4j.dtd 2001/10/04 21:07:04 1.12 +++ log4j.dtd 2001/11/17 01:04:22 1.13 @@ -2,6 +2,8 @@ <!-- Authors: Chris Taylor, Ceki Gulcu. --> +<!-- Version: 1.2 --> + <!-- A configuration element consists of optional renderer elements,appender elements, categories and an optional root element. --> @@ -58,7 +60,7 @@ <!-- ErrorHandlers can be of any class. They can admit any number of --> <!-- parameters. --> -<!ELEMENT errorHandler (param*)> +<!ELEMENT errorHandler (param*, appender-ref?)> <!ATTLIST errorHandler class CDATA #REQUIRED > -- To unsubscribe, e-mail: <mailto:larryaguilar@example.net> For additional commands, e-mail: <mailto:larryaguilar@example.net> From log4j-cvslarryaguilar@example.net Sat Nov 17 10:26:24 2001 Return-Path: <log4j-cvslarryaguilar@example.net> Delivered-To: larryaguilar@example.net Received: (qmail 78685 invoked from network); 17 Nov 2001 10:26:24 -0000 Received: from unknown (HELO nagoya.betaversion.org) (83.161.120.155) by daedalus.apache.org with SMTP; 17 Nov 2001 10:26:24 -0000 Received: (qmail 13107 invoked by uid 97); 17 Nov 2001 10:26:35 -0000 Delivered-To: larryaguilar@example.net Received: (qmail 13048 invoked by uid 97); 17 Nov 2001 10:26:34 -0000 Mailing-List: contact larryaguilar@example.net; run by ezmlm Precedence: bulk List-Unsubscribe: <mailto:larryaguilar@example.net> List-Subscribe: <mailto:larryaguilar@example.net> List-Help: <mailto:larryaguilar@example.net> List-Post: <mailto:larryaguilar@example.net> List-Id: "Log4J CVS List" <log4j-cvs.jakarta.apache.org> Reply-To: "Log4J Developers List" <larryaguilar@example.net> Delivered-To: mailing list larryaguilar@example.net Received: (qmail 13037 invoked from network); 17 Nov 2001 10:26:34 -0000 Date: 17 Nov 2001 10:12:27 -0000 Message-ID: <larryaguilar@example.net> From: larryaguilar@example.net To: larryaguilar@example.net Subject: cvs commit: jakarta-log4j/src/java/org/apache/log4j/varia FallbackErrorHandler.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ceki 01/11/17 02:12:27 Modified: src/java/org/apache/log4j/spi ErrorHandler.java src/java/org/apache/log4j/varia FallbackErrorHandler.java Log: Corrected silly typos. The setLogger(String) method in ErrorHandler interface is likely to change back to setLogger(Logger). Submitted by: Jeff Turner Revision Changes Path 1.5 +1 -1 jakarta-log4j/src/java/org/apache/log4j/spi/ErrorHandler.java Index: ErrorHandler.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/ErrorHandler.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ErrorHandler.java 2001/11/17 01:04:22 1.4 +++ ErrorHandler.java 2001/11/17 10:12:26 1.5 @@ -38,7 +38,7 @@ for the failing appender in view of replacement. @since 1.2 */ - void setLogger(Stiring loggerName); + void setLogger(String loggerName); /** 1.2 +2 -2 jakarta-log4j/src/java/org/apache/log4j/varia/FallbackErrorHandler.java Index: FallbackErrorHandler.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/varia/FallbackErrorHandler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- FallbackErrorHandler.java 2001/11/17 01:04:22 1.1 +++ FallbackErrorHandler.java 2001/11/17 10:12:27 1.2 @@ -45,8 +45,8 @@ if(loggers == null) { loggers = new Vector(); } - if(loggerName.equalsIgnoreCase - loggers.add(logger); + //if(loggerName.equalsIgnoreCase + //loggers.add(logger); } -- To unsubscribe, e-mail: <mailto:larryaguilar@example.net> For additional commands, e-mail: <mailto:larryaguilar@example.net> From log4j-cvslarryaguilar@example.net Sun Nov 18 13:11:53 2001 Return-Path: <log4j-cvslarryaguilar@example.net> Delivered-To: larryaguilar@example.net Received: (qmail 39001 invoked from network); 18 Nov 2001 13:11:53 -0000 Received: from unknown (HELO nagoya.betaversion.org) (83.161.120.155) by daedalus.apache.org with SMTP; 18 Nov 2001 13:11:53 -0000 Received: (qmail 2933 invoked by uid 97); 18 Nov 2001 13:11:52 -0000 Delivered-To: larryaguilar@example.net Received: (qmail 2897 invoked by uid 97); 18 Nov 2001 13:11:51 -0000 Mailing-List: contact larryaguilar@example.net; run by ezmlm Precedence: bulk List-Unsubscribe: <mailto:larryaguilar@example.net> List-Subscribe: <mailto:larryaguilar@example.net> List-Help: <mailto:larryaguilar@example.net> List-Post: <mailto:larryaguilar@example.net> List-Id: "Log4J CVS List" <log4j-cvs.jakarta.apache.org> Reply-To: "Log4J Developers List" <larryaguilar@example.net> Delivered-To: mailing list larryaguilar@example.net Received: (qmail 2886 invoked from network); 18 Nov 2001 13:11:50 -0000 Date: 18 Nov 2001 12:57:26 -0000 Message-ID: <larryaguilar@example.net> From: larryaguilar@example.net To: larryaguilar@example.net Subject: cvs commit: jakarta-log4j/src/java/org/apache/log4j/xml DOMConfigurator.java log4j.dtd X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ceki 01/11/18 04:57:26 Modified: src/java/org/apache/log4j Category.java FileAppender.java src/java/org/apache/log4j/helpers OnlyOnceErrorHandler.java src/java/org/apache/log4j/spi ErrorHandler.java src/java/org/apache/log4j/test/xml fallback1.xml src/java/org/apache/log4j/varia FallbackErrorHandler.java src/java/org/apache/log4j/xml DOMConfigurator.java log4j.dtd Log: FallbackErrorHandler actually performs a useful action now. Further tests are still needed. Revision Changes Path 1.55 +7 -2 jakarta-log4j/src/java/org/apache/log4j/Category.java Index: Category.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/Category.java,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- Category.java 2001/11/17 01:04:21 1.54 +++ Category.java 2001/11/18 12:57:26 1.55 @@ -465,6 +465,8 @@ /** Return the default Hierarchy instance. + @deprecated Please use {@link LogManager.getLoggerRepository()} instead. + @since 1.0 */ public @@ -477,7 +479,7 @@ Return the the {@link Hierarchy} where this <code>Category</code> instance is attached. - @deprecatede Please use {@link #getLoggerRepository} instead. + @deprecated Please use {@link #getLoggerRepository} instead. @since 1.1 */ public @@ -718,10 +720,13 @@ */ public boolean isAttached(Appender appender) { + System.err.println(getName()+"=-=-=-=-=-=-["+appender+"-"+aai); if(appender == null || aai == null) return false; - else + else { + System.err.println(".......=-=-=-=-=-=-["+appender); return aai.isAttached(appender); + } } /** 1.32 +2 -1 jakarta-log4j/src/java/org/apache/log4j/FileAppender.java Index: FileAppender.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/FileAppender.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- FileAppender.java 2001/11/17 01:04:21 1.31 +++ FileAppender.java 2001/11/18 12:57:26 1.32 @@ -96,7 +96,8 @@ <code>filename</code> will be truncated before being opened. */ public - FileAppender(Layout layout, String filename, boolean append) throws IOException { + FileAppender(Layout layout, String filename, boolean append) + throws IOException { this.layout = layout; this.setFile(filename, append, false, bufferSize); } 1.9 +1 -1 jakarta-log4j/src/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java Index: OnlyOnceErrorHandler.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/helpers/OnlyOnceErrorHandler.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- OnlyOnceErrorHandler.java 2001/11/17 01:04:22 1.8 +++ OnlyOnceErrorHandler.java 2001/11/18 12:57:26 1.9 @@ -39,7 +39,7 @@ Does not do anything. */ public - void setLogger(String loggerName) { + void setLogger(Logger logger) { } 1.6 +3 -3 jakarta-log4j/src/java/org/apache/log4j/spi/ErrorHandler.java Index: ErrorHandler.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/ErrorHandler.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ErrorHandler.java 2001/11/17 10:12:26 1.5 +++ ErrorHandler.java 2001/11/18 12:57:26 1.6 @@ -34,11 +34,11 @@ be attached to. The failing appender will be searched and replaced only in the loggers you add through this method. - @param loggerName The name of the logger that will be searched - for the failing appender in view of replacement. + @param logger One of the loggers that will be searched for the failing + appender in view of replacement. @since 1.2 */ - void setLogger(String loggerName); + void setLogger(Logger logger); /** 1.2 +2 -2 jakarta-log4j/src/java/org/apache/log4j/test/xml/fallback1.xml Index: fallback1.xml =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/test/xml/fallback1.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- fallback1.xml 2001/11/17 01:04:22 1.1 +++ fallback1.xml 2001/11/18 12:57:26 1.2 @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> -<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> +<log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="PRIMARY" class="org.apache.log4j.FileAppender"> <errorHandler class="org.apache.log4j.varia.FallbackErrorHandler"> - <param name="logger" value="root"/> + <root-ref/> <appender-ref ref="FALLBACK" /> </errorHandler> 1.3 +16 -8 jakarta-log4j/src/java/org/apache/log4j/varia/FallbackErrorHandler.java Index: FallbackErrorHandler.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/varia/FallbackErrorHandler.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- FallbackErrorHandler.java 2001/11/17 10:12:27 1.2 +++ FallbackErrorHandler.java 2001/11/18 12:57:26 1.3 @@ -12,6 +12,7 @@ import org.apache.log4j.spi.LoggingEvent; import org.apache.log4j.Appender; import org.apache.log4j.Logger; +import org.apache.log4j.helpers.LogLog; import java.util.Vector; /** @@ -41,12 +42,12 @@ loggers that we need to search for in case of appender failure. */ public - void setLogger(String loggerName) { + void setLogger(Logger logger) { + LogLog.debug("FB: Adding logger [" + logger.getName() + "]."); if(loggers == null) { loggers = new Vector(); } - //if(loggerName.equalsIgnoreCase - //loggers.add(logger); + loggers.add(logger); } @@ -74,11 +75,16 @@ void error(String message, Exception e, int errorCode, LoggingEvent event) { for(int i = 0; i < loggers.size(); i++) { Logger l = (Logger) loggers.get(i); - if(l.isAttached(primary)) { - l.removeAppender(primary); - l.addAppender(backup); - } - } + LogLog.debug("FB: Searching for ["+primary.getName()+"] in logger" + +l.getName()); + //if(l.isAttached(primary)) { + LogLog.debug("FB: Replacing ["+primary.getName()+"] by [" + + backup.getName() + " in logger"+ l); + l.removeAppender(primary); + LogLog.debug("FB: Adding appender ["+backup.getName()+"] to logger " + + l.getName()); + l.addAppender(backup); + } } @@ -99,6 +105,7 @@ */ public void setAppender(Appender primary) { + LogLog.debug("FB: Setting primary appender to [" + primary.getName() + "]."); this.primary = primary; } @@ -107,6 +114,7 @@ */ public void setBackupAppender(Appender backup) { + LogLog.debug("FB: Setting backup appender to [" +
{'source': 'Apache Software Foundation Public Mail Archives'}