You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-cvs@jakarta.apache.org by ce...@apache.org on 2001/10/12 09:05:12 UTC

cvs commit: jakarta-log4j/src/java/org/apache/log4j/xml SAXErrorHandler.java

ceki        01/10/12 00:05:12

  Modified:    docs     HISTORY
               src/docbook configuration.xml defaultInit.xml
               src/java/org/apache/log4j/test/xml domTest4.xml
               src/java/org/apache/log4j/xml SAXErrorHandler.java
  Log:
  doc changes
  
  Revision  Changes    Path
  1.69      +5 -8      jakarta-log4j/docs/HISTORY
  
  Index: HISTORY
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/docs/HISTORY,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- HISTORY	2001/09/28 13:37:47	1.68
  +++ HISTORY	2001/10/12 07:05:11	1.69
  @@ -5,16 +5,13 @@
          client code. 
    [***] Changes requiring important modifications to existing client code.
   
  - September 26, 2001
  + October ??, 2001
    
  - - Release of version 1.2alpha_1
  + - Release of version 1.2
   
  - - This alpha release consists of documentation changes. [*]
  -
  - September 25, 2001
  - 
  - - Release of version 1.2alpha_0
  -
  + - Improved error reporting in DOMConfigurator. Thanks to Thomas Tuft
  +   Muller for contributing the enhancement. [*]
  +	
    - Log4j is now configurable using JMX. [*]
   
    - Modified SMTPAppender to allow multiple email sessions. Thanks to
  
  
  
  1.12      +55 -22    jakarta-log4j/src/docbook/configuration.xml
  
  Index: configuration.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/docbook/configuration.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- configuration.xml	2001/10/02 21:53:05	1.11
  +++ configuration.xml	2001/10/12 07:05:11	1.12
  @@ -156,7 +156,7 @@
   
      public static void main(String[] args) {
   
  -     
  +	
        // BasicConfigurator replaced with PropertyConfigurator.
        PropertyConfigurator.configure(args[0]);
   
  @@ -231,7 +231,7 @@
     </para>
       
       <para>
  -      <example><title>XML equivalent configuration file</title>
  +      <example><title>Equivalent configuration file in XML</title>
         <screen>
   &lt;?xml version="1.0" encoding="UTF-8" ?>
   &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
  @@ -261,14 +261,22 @@
     </sect1>
   
     <sect1>
  -    <title>Filtering by logger level</title>
  +    <title>PropertyConfigurator: Filtering by request level</title>
   
  -    <para>Suppose we are no longer interested in seeing the output of
  -      any component belonging to the <classname>com.foo</classname>
  -      package. The following configuration file shows one efficient
  -      way of achieving this. In <xref linkend="thresholdFiltering"/>
  -      and <xref linkend="configuringFilters"/> and we discuss
  -      alternate was of achieving a similar effect.
  +    <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.
  +    </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.
       </para>
   
       <para>
  @@ -278,8 +286,7 @@
   log4j.appender.A1=org.apache.log4j.ConsoleAppender
   log4j.appender.A1.layout=org.apache.log4j.PatternLayout
     
  -# <emphasis role="bold">Print the date in ISO 8601 format</emphasis>
  -log4j.appender.A1.layout.ConversionPattern=<emphasis role="bold">%d</emphasis> [%t] %-5p %c - %m%n
  +log4j.appender.A1.layout.ConversionPattern=[%t] %-5p %c - %m%n
     
   # Print only messages of priority WARN or above in the package com.foo.
   <emphasis role="bold">log4j.logger.com.foo=WARN</emphasis>
  @@ -306,7 +313,7 @@
     </sect1>
     
     <sect1>
  -    <title>Filtering by logger level using <classname>DOMConfigurator</classname></title>
  +    <title><classname>DOMConfigurator</classname>: Filtering by logger level</title>
       
       <para>
         <example><title>XML equivalent configuration file</title>
  @@ -435,7 +442,7 @@
     </sect1>
         
     <sect1 id="thresholdFiltering">
  -    <title>Directing log output to different appenders depending on level</title>
  +    <title>PropertyConfigutaor: Level-based filters on Appenders</title>
   
       <para>Setting the <emphasis role="bold">Threshold</emphasis> option
         of any appender extending AppenderSkeleton, (most log4j
  @@ -445,16 +452,14 @@
   
       <para>For example, setting the threshold of an appender to DEBUG
         also allow INFO, WARN, ERROR and FATAL messages to log along
  -      with DEBUG messages. (DEBUG is the lowest priority). This is
  +      with DEBUG messages. (DEBUG is the lowest level). This is
         usually acceptable as there is little use for DEBUG messages
         without the surrounding INFO, WARN, ERROR and FATAL
         messages. Similarly, setting the threshold of an appender to
         ERROR will filter out DEBUG, INFO and ERROR messages but not
  -      FATAL messages.
  -    </para>
  -
  -    <para>This policy usually best encapsulates what the user actually
  -      wants to do, as opposed to her mind-projected solution.
  +      FATAL messages. This policy usually best encapsulates what the
  +      user actually wants to do, as opposed to her mind-projected
  +      solution.
       </para>
       
       <para>See sort4.lcf for an example threshold configuration. </para>
  @@ -482,10 +487,38 @@
   0    [main] INFO  MyApp  - Entering application.
   51   [main] INFO  MyApp  - Exiting application.
       </screen>
  +
  +    <para>If you must filter events by exact level match, then you can
  +      attach a LevelMatchFilter to any appender to filter out logging
  +      events by exact level match.</para>
  +  </sect1>
  +
  +  <sect1>
  +    <title>DOMConfigurator: Level-based filters on Appenders</title>
  +    
  +    <para>The following XML file has the same effect as the key=value
  +    configuration file listed previously.</para>
   
  -    <para>If you must filter events by exact priority match, then you can
  -      attach a PriorityMatchFilter to any appender to filter out logging
  -      events by exact priority match.</para>
  +    <programlisting>
  + &lt;?xml version="1.0" encoding="UTF-8" ?>
  +  &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
  +	  
  +  &lt;log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
  +	  
  +  &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"/>
  +      &lt;param name="Threshold" value="INFO"/>
  +    &lt;/layout>	                 
  +  &lt;/appender>
  +
  + &lt;root>
  +   &lt;priority value ="debug" />
  +   &lt;appender-ref ref="STDOUT" />
  + &lt;/root>
  +	
  +&lt;/log4j:configuration>
  +    </programlisting>
     </sect1>
   
     <sect1>
  
  
  
  1.2       +154 -65   jakarta-log4j/src/docbook/defaultInit.xml
  
  Index: defaultInit.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/docbook/defaultInit.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- defaultInit.xml	2001/10/01 21:14:54	1.1
  +++ defaultInit.xml	2001/10/12 07:05:11	1.2
  @@ -8,7 +8,7 @@
         to automatically configure log4j. The Java language guarantees
         that the static initializer of a class is called once and only
         once during the loading of a class into memory. It is important
  -      to remember that different classloaders may load distinct copies
  +    to remember that different classloaders may load distinct copies
         of the same class. These copies of the same class are considered
         as totally unrelated by the JVM.
       </para>
  @@ -34,11 +34,12 @@
   
         <step>
   	<para>Set the <classname>resource</classname> string variable
  -	  to the value of the <command>log4j.configuration</command> system
  -	  property.  <emphasis>The preferred way to specify the default
  -	  initialization file is thourough the
  -	  <emphasis role="bold">log4j.configuration</emphasis> system property.</emphasis> In case the
  -	  system property <emphasis role="bold">log4j.configuration</emphasis> is not defined,
  +	  to the value of the <command>log4j.configuration</command>
  +	  system property.  <emphasis>The preferred way to specify the
  +	  default initialization file is thourough the <emphasis
  +	  role="bold">log4j.configuration</emphasis> system
  +	  property.</emphasis> In case the system property <emphasis
  +	  role="bold">log4j.configuration</emphasis> is not defined,
   	  then set the string variable <classname>resource</classname>
   	  to its default value "log4j.properties".
   	</para>
  @@ -46,48 +47,45 @@
   
         <step>
   	<para>Attempt to convert the <classname>resource</classname>
  -	  for the list of searched locations.variable to a
  -	  URL.
  +	  variable to a URL.
   	</para>
         </step>
   
         <step>
   	<para>If the resource variable cannot be converted to a URL,
  -	  for the list of searched locations.for
  -	  example due to a
  -	  for the list of searched
  - for the list of searched locations.locations.<classname>MalformedURLException</classname>,
  - for the list of searched locations.then search for
  - the <classname>resource</classname> from the classpath by calling
  - <classname>org.apache.log4j.helpers.Loader.getResource(resource,
  - Logger.class)</classname> which returns a URL.  Note that the string
  - "log4j.properties" constitutes a malformed URL.
  +	  due for example to a
  +	  <classname>MalformedURLException</classname>, then search
  +	  for <classname>resource</classname> from the classpath by
  +	  calling
  +	  <classname>org.apache.log4j.helpers.Loader.getResource(resource,
  +	  Logger.class)</classname> which returns a URL.  Note that
  +	  the string "log4j.properties" constitutes a malformed URL.
   	</para>
   
   	<para>See <ulink
  -	    url="api/org/apache/log4j/helpers/Loader.html#getResource(java.lang.String)">Loader.getResource(java.lang.String)</ulink>
  -	  for the list of searched locations.</para>
  +	    url="../api/org/apache/log4j/helpers/Loader.html#getResource(java.lang.String)">Loader.getResource(java.lang.String)</ulink>
  +	    for the list of searched locations.</para>
         </step>
   
         
         <step>
   	<para>If no URL could not be found, abort default
  - initialization. Otherwise, configure log4j from the URL.
  +	initialization. Otherwise, configure log4j from the URL.
   	</para>
   
   	<para>The <ulink
  -	    url="api/org/apache/log4j/PropertyConfigurator.html">PropertyConfigurator</ulink>
  +	    url="../api/org/apache/log4j/PropertyConfigurator.html">PropertyConfigurator</ulink>
   	  will be used to parse the URL to configure log4j unless the
  -	  for the list of searched locations.URL ends with the ".xml"
  -	  for the list of searched locations.extension, in which case the
  -	  for the list of searched locations.<ulink
  -	    url="api/org/apache/log4j/xml/DOMConfigurator.html">DOMConfigurator</ulink>
  +	  URL ends with the ".xml"
  +	  extension, in which case the
  +	  <ulink
  +	    url="../api/org/apache/log4j/xml/DOMConfigurator.html">DOMConfigurator</ulink>
   	  will be used. You can optionaly specify a custom configurator. The
   	  value of the <emphasis role="bold">log4j.configuratorClass</emphasis> system property is taken
   	  as the fully qualified class name of your custom configurator. The
   	  custom configurator you specify <emphasis>must</emphasis> implement
   	  the <ulink
  -	    url="api/org/apache/log4j/spi/Configurator.html">Configurator</ulink>
  +	    url="../api/org/apache/log4j/spi/Configurator.html">Configurator</ulink>
   	  interface.
   	</para>
         </step>
  @@ -104,18 +102,19 @@
   	web-server environments. Under Tomcat 3.x and 4.x, you should place
   	the <classname>log4j.properties</classname> under the
   	<classname>WEB-INF/classes</classname> directory of your
  -	for the list of searched locations.web-applications. Log4j
  -	for the list of searched locations.will find the properties file and
  -	for the list of searched locations.initialize itself. This is easy to
  +	web-applications. Log4j
  +	will find the properties file and
  +	initialize itself. This is easy to
   	do and it works.
         </para>
   
  -      <para>You can also choose to set the system property
  -	<emphasis role="bold">log4j.configuration</emphasis> before starting Tomcat. For Tomcat 3.x The
  -	<classname>TOMCAT_OPTS</classname> environment variable is used to set command
  -	line options. For Tomcat 4.0, set the <classname>CATALINA_OPTS</classname>
  +      <para>You can also choose to set the system property <emphasis
  +	role="bold">log4j.configuration</emphasis> before starting
  +	Tomcat. For Tomcat 3.x The <classname>TOMCAT_OPTS</classname>
  +	environment variable is used to set command line options. For
  +	Tomcat 4.0, set the <classname>CATALINA_OPTS</classname>
   	environment variable instead of
  - for the list of searched locations.<classname>TOMCAT_OPTS</classname>.
  +	<classname>TOMCAT_OPTS</classname>.
         </para>
   
         <example>
  @@ -126,18 +125,13 @@
   	</computeroutput>
   
   	tells log4j to use the file <classname>foobar.txt</classname>
  -	for the list of searched locations.as the default
  -	configuration file. This file should be place under the
  -	<classname>WEB-INF/classes</classname> directory of your
  - for the list of searched locations.web-application. The file will be
  - for the list of searched locations.read using the <ulink
  -	  url="api/org/apache/log4j/xml/PropertyConfigurator.html">PropertyConfigurator</ulink>. Each
  - for the list of searched locations.for the list of searched
  - for the list of searched locations.locations.web-application will use
  - for the list of searched locations.a different default configuration
  - for the list of searched locations.for the list of searched
  - for the list of searched locations.locations.file because each file
  - for the list of searched locations.is relative to a web-application.
  +	as the default configuration file. This file should be place
  +	under the <classname>WEB-INF/classes</classname> directory of
  +	your web-application. The file will be read using the <ulink
  +	url="../api/org/apache/log4j/xml/PropertyConfigurator.html">PropertyConfigurator</ulink>. Each
  +	web-application will use a different default configuration for
  +	the list of searched locations.file because each file is
  +	relative to a web-application.
   	</para>
         </example>
   
  @@ -150,20 +144,17 @@
   	  </computeroutput>
   
   	  tells log4j to output log4j-internal debugging information
  - for the list of searched locations.for the list of searched
  - for the list of searched locations.locations.and to use the file for
  - for the list of searched locations.the list of searched for the list
  - for the list of searched locations.of searched
  - for the list of searched locations.locations.locations.<classname>foobar.xml</classname>
  - for the list of searched locations.as the default configuration
  - for the list of searched locations.file. This file should be place
  - for the list of searched locations.under the
  - for the list of searched locations.<classname>WEB-INF/classes</classname>
  -	  directory of your web-application. Since the file ends with a
  -	  <classname>.xml</classname> extension, it will read using the <ulink
  -	    url="api/org/apache/log4j/xml/DOMConfigurator.html">DOMConfigurator</ulink>. Each
  -	  web-application will use a different default configuration file because
  -	  each file is relative to a web-application.
  +	  for the list of searched locations.and to use the file for
  +	  the list of searched for the list of searched
  +	  locations.locations.<classname>foobar.xml</classname> as the
  +	  default configuration file. This file should be place under
  +	  the <classname>WEB-INF/classes</classname> directory of your
  +	  web-application. Since the file ends with a
  +	  <classname>.xml</classname> extension, it will read using
  +	  the <ulink
  +	  url="../api/org/apache/log4j/xml/DOMConfigurator.html">DOMConfigurator</ulink>. Each
  +	  web-application will use a different default configuration
  +	  file because each file is relative to a web-application.
   	</para>
         </example>
   
  @@ -250,7 +241,7 @@
       </para>
   
       <para>Define the following servlet in the web.xml file for your
  - for the list of searched locations.web-application.</para>
  +      web-application.</para>
       
   	
       <para>
  @@ -271,8 +262,106 @@
   	</para>
   
   	<para>Writing an initialization servlet is the most flexible
  - for the list of searched locations.way for
  -initializing log4j. There are no constraints on the classname you can place
  -in the <classname>init()</classname> method of the servlet.</para>
  -    </sect1>
  +      way for initializing log4j. There are no constraints on the
  +      classname you can place in the <classname>init()</classname>
  +      method of the servlet.</para>
  +  </sect1>
  +
  +  <sect1>
  +    <title>Initilization of log4j in Enterprise Java Beans</title>
  +    <sect2>
  +      <title>JBoss</title>
  +      
  +      <para>As of version 2.4, JBoss uses log4j for its own
  +      logging. Consequently, your own EJBs and web applications will
  +      automatically inherit jBoss' log4j configuration.</para>
  +
  +      <para>More often than not you to keep your application's logs
  +       separate from the Application Server log. JBoss adopting log4j
  +       is a step backward in some sense. There are a number of
  +       possible solutions.</para>
  +
  +      <para>The easiest solution is to modify jboss' log4j
  +      configuration file. Assuming all your classes live under
  +      <classname>com.wombat</classname> package or packages under it,
  +      configuring a a category called
  +      <classname>com.wombat</classname> and setting it's level and
  +      additivity will isolate all categories under it effectively
  +      isolating logging from your code from that of JBoss. For this
  +      approach to work properly your code should not make use of the
  +      categories that JBoss uses such as those under
  +      <classname>org.jboss</classname> nor the root category.
  +      </para>
  +
  +    </sect2>
  +
  +    <sect2>
  +      <title>Weblogic 6.x</title>
  +      
  +      <para>One simple but somewhat inflexible approach for using
  +      log4j under weblogic is to add log4j.jar to the system classpath
  +      before launching Weblogic server. This is guaranteed to work
  +      except that all applications will be sharing the same instance
  +      of the log4j classes and consequently share the same log4j
  +      configuration.</para>
  +      
  +      <para>However, it is also possible to have Weblogic load a
  +      separate instance of log4j classes per appliction. Altough not
  +      difficult this approach requires some rudimentary understanding
  +      of the way Weblogic loads your applications.</para>
  +
  +      <para>Contrary to version 5.x, when WebLogic Server 6.x deploys
  +      an application, it creates two new classloaders: one for EJBs
  +      and one for Web applications. The first, the so called "EJB
  +      classloader" is a child of the system classloader. The second,
  +      the so called "Web-application" classloader is a child of the
  +      EJB classloader. Thus, classes in the web-application can access
  +      the classes in your enterprise beans but not vice versa. See
  +      <ulink
  +      url="http://e-docs.bea.com/wls/docs61/programming/packaging.html#pack013">Weblogic
  +      Classloader Overview</ulink> for more details.
  +      </para>
  +
  +      <para>As far as I know, contrary to Servlet Containers which are
  +	required to load classes and jar files located under the
  +	/WEB-INF/classes and /WEB-INF/lib directory, there is no
  +	standard location that the EJB container will search in order
  +	to load your utility classes. As mentioned earlier, one
  +	solution to circumvent this problem is to add log4j to the
  +	Java system classpath with the aforementioned
  +	limitations. Another approach is to include log4j.jar within
  +	your EJB jar files. This has the distinct disadvantage of
  +	bloat.
  +      </para>
  +
  +      <para>There is a better and quite elegant approach.  Version 1.2
  +      of the Java platform, added support for <ulink
  +      url="http://java.sun.com/products/jdk/1.2/docs/guide/extensions/spec.html">bundled
  +      extensions</ulink> for jar files. A jar file can specify the
  +      relative URLs of extensions and libraries that it requires via
  +      the the "Class-Path" manifest attribute.
  +      </para>
  +
  +	An application (or, more generally, JAR file) specifies the
  +	relative URLs of the extensions (and libraries) that it needs
  +	via the manifest attribute Class-Path. This attribute lists
  +	the URLs to search for implementations of extensions (or other
  +	libraries) if they cannot be found as extensions installed on
  +	the host Java virtual machine. These relative URLs may include
  +	JAR files and directories for any libraries or resources
  +	needed by the application or extension. Relative URLs not
  +	ending with '/' are assumed to refer to JAR files. For
  +	example,
  +
  +      
  +    </sect2>
  +
  +    <sect2>
  +      <title>IBM Websphere</title>
  +
  +      <para>I have no personal experience with IBM's Websphere. 
  +
  +      </para>
  +    </sect2>
  +  </sect1>
     </chapter>
  
  
  
  1.2       +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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- domTest4.xml	2001/10/04 20:57:57	1.1
  +++ domTest4.xml	2001/10/12 07:05:12	1.2
  @@ -14,8 +14,8 @@
     <category name="org.apache.log4j.xml">
       <priority value="inherited"/>
     </category>
  -  <root>
  +  <rot>
       <priority value="error"/>
       <appender-ref ref="A1" />	       
  -  </root>
  +  </rot>
   </log4j:configuration>
  
  
  
  1.2       +1 -0      jakarta-log4j/src/java/org/apache/log4j/xml/SAXErrorHandler.java
  
  Index: SAXErrorHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/SAXErrorHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SAXErrorHandler.java	2001/10/04 21:07:04	1.1
  +++ SAXErrorHandler.java	2001/10/12 07:05:12	1.2
  @@ -18,6 +18,7 @@
       LogLog.error("Parsing error on line "+ex.getLineNumber()+" and column "
   		 +ex.getColumnNumber());
       LogLog.error(ex.getMessage(), ex.getException());
  +    //LogLog.error("pid="+ex.getPublicId()+" sid="+ex.getSystemId());
     }
     
     public
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-cvs-help@jakarta.apache.org