You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by je...@um.edu.mt on 2001/03/01 17:49:29 UTC

Turn off logging, and getHeader()/getFooter() in layout class


Hi all, and good evening ceki (you will probably be the only one to answer 
this),

I am using log4j and it meets almost all my requirements.  However I have two 
questions

(1) How do I turn all logging off from the CONFIG file ?  What do I need to set 
?  If the user does not want to log anything how should he configure the config 
file ?  

(2) I have created my own layout class (to output in xml) and I would like to 
set an appropriate xml header (I subclasses layout and overridden the 
getHeader() method)

public String getHeader() {
  
    StringBuffer buf = new StringBuffer();
    
    buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
     
    return buf.toString();
  }

while everything in the layout is ok, this header never appears anywhere in the 
log file.  The same can be said if you try to set a footer.  Why ?  (I am using 
fileappender)...

ANy Ideas Please anyone ? 

Thanks
JP


Re: Turn off logging, and getHeader()/getFooter() in layout class

Posted by Ceki Gülcü <cg...@qos.ch>.
At 17:49 01.03.2001 +0100, jebe002@um.edu.mt wrote:


>Hi all, and good evening ceki (you will probably be the only one to answer 
>this),
>
>I am using log4j and it meets almost all my requirements.  However I have two 
>questions
>
>(1) How do I turn all logging off from the CONFIG file ?  What do I need to set 
>?  If the user does not want to log anything how should he configure the config 
>file ?  

JP,

This is from the 1.1beta1 HISTORY file:

 - Logging can now be disabled per Hierarchy. It can also be disabled
   using configuration files using the "disable" directive.  The
   disableOverride directive takes precedence over the disable
   directive.  As a result of this change the disable family of
   methods has moved from the BasicConfigurator class to the Hierarchy
   class. [**]

>(2) I have created my own layout class (to output in xml) and I would like to 
>set an appropriate xml header (I subclasses layout and overridden the 
>getHeader() method)
>
>public String getHeader() {
>  
>    StringBuffer buf = new StringBuffer();
>    
>    buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
>     
>    return buf.toString();
>  }
>
>while everything in the layout is ok, this header never appears anywhere in the 
>log file.  The same can be said if you try to set a footer.  Why ?  (I am using 
>fileappender)...


This is a bug/omission that was fixed in 1.1b1. Hope this helps, Ceki