cziegeler    01/08/09 05:25:35

  Modified:    src/org/apache/cocoon/servlet CocoonServlet.java
               webapp/WEB-INF web.xml
  Added:       src/org/apache/cocoon/util/log XMLCocoonLogFormatter.java
  Log:
  Added simple xml log formatter and configuration option in web.xml
  
  Revision  Changes    Path
  1.26      +14 -4     xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- CocoonServlet.java        2001/08/07 10:18:18     1.25
  +++ CocoonServlet.java        2001/08/09 12:25:35     1.26
  @@ -43,7 +43,9 @@
   import org.apache.cocoon.util.IOUtils;
   import org.apache.cocoon.util.NetUtils;
   import org.apache.cocoon.util.log.CocoonLogFormatter;
  +import org.apache.cocoon.util.log.XMLCocoonLogFormatter;
   import org.apache.log.ContextStack;
  +import org.apache.log.Formatter;
   import org.apache.log.Hierarchy;
   import org.apache.log.LogTarget;
   import org.apache.log.Logger;
  @@ -62,7 +64,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a> Aisa
    * @author <a href="mailto:[EMAIL PROTECTED]";>Berin Loritsch</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.25 $ $Date: 2001/08/07 10:18:18 $
  + * @version CVS $Revision: 1.26 $ $Date: 2001/08/09 12:25:35 $
    */
   
   public class CocoonServlet extends HttpServlet {
  @@ -312,6 +314,7 @@
           final Priority logPriority;
           String logDir = getInitParameter("log-dir");
           String logLevel = getInitParameter("log-level");
  +        String logFormat = getInitParameter("log-format");
           if (logLevel != null) {
               logLevel.trim();
           }
  @@ -342,10 +345,17 @@
               this.appContext.put(Constants.CONTEXT_LOG_FILE, logName);
   
               final String path = logDir + logName;
  -            final CocoonLogFormatter formatter = new CocoonLogFormatter();
  -            formatter.setFormat( "%7.7{priority} %{time}   [%8.8{category}] " +
  +            Formatter formatter;
  +            if (logFormat == null || logFormat.equalsIgnoreCase("xml") == false) {
  +                final CocoonLogFormatter cf = new CocoonLogFormatter();
  +                cf.setFormat( "%7.7{priority} %{time}   [%8.8{category}] " +
                                    "(%{uri}) %{thread}/%{class:short}: 
%{message}\\n%{throwable}" );
  -
  +                formatter = cf;
  +            } else {
  +                final XMLCocoonLogFormatter cf = new XMLCocoonLogFormatter();
  +                cf.setTypes("priority time category uri thread class message 
throwable");
  +                formatter = cf;
  +            }
               this.log = Hierarchy.getDefaultHierarchy().getLoggerFor("cocoon");
               this.log.setPriority(logPriority);
   
  
  
  
  1.2       +340 -0    
xml-cocoon2/src/org/apache/cocoon/util/log/XMLCocoonLogFormatter.java
  
  
  
  
  1.9       +11 -0     xml-cocoon2/webapp/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/webapp/WEB-INF/web.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- web.xml   2001/07/27 18:41:00     1.8
  +++ web.xml   2001/08/09 12:25:35     1.9
  @@ -23,6 +23,7 @@
         use the following servlet-class instead of the normal one
   
         <servlet-class>org.apache.cocoon.servlet.ParanoidCocoonServlet</servlet-class>
  +
       -->
       <servlet-class>org.apache.cocoon.servlet.CocoonServlet</servlet-class>
   
  @@ -83,6 +84,16 @@
       <init-param>
         <param-name>log-name</param-name>
         <param-value>cocoon.log</param-value>
  +    </init-param>
  +    -->
  +  
  +    <!-- 
  +      This parameter specifies the format of the log. You can choose between xml
  +      and text, default is text.
  +
  +    <init-param>
  +      <param-name>log-format</param-name>
  +      <param-value>xml</param-value>
       </init-param>
       -->
     
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to