Hi Julie,

If your code writes to a category, then that category "exists",
whether it is defined in the configuration file or not.

What you can do is set up the configuration file so that
the logging level of the category is so high that all 
messages get discarded, which I think is what you
are trying to do. 
eg:
        log4j.category.console.cat = FATAL

Note that by "commenting out" the config
file entry, you are causing the category logging level to
default to "inherited", which in your example ends up
being the rootCategory level of "debug".

I must say that I don't quite understand why you 
are using log4j in the way described below..why
have a special category for "console"?? If you
instead write your debug messages to the category
logically associated with each piece of code, at
a debug LEVEL (ie cat.debug("debug msg")) then
you can filter these out by setting the category
log level....and any category can be sent to as
many different appenders as is required. I don't
mean to imply your code is wrong, I just am
a bit puzzled...

Regards,

Simon

> -----Original Message-----
> From: Julie F McCabe [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, February 13, 2001 3:43 PM
> To:   [EMAIL PROTECTED]
> Subject:      configuring appenders
> 
> Hi all,
> 
> I have managed to get very confused with log4j & seem to be missing the
> efficiency it has to offer.  My problem is I have created my own category,
> the
> aim is to write to 4 different files with the respective cat1 - cat4
> categorties
> and the console category for writting to system.out for debugging purposes
> only.
> Therefore in the config file below, if I comment out
> log4j.category.console.cat
> = INFO then I should have no logging to system.out, right?  However, the
> particular implementation does not work as expected.  Any suggestions?
> Basically I want to have a category that I can switch off from the config
> file
> once the program goes into production.
> 
> Thanks,
> Julie Mc Cabe
> 
> 
> config file:
> 
> log4j.categoryFactory=com.jpmorgan.researchcontent.transmit.TransmitCatego
> ryFactory
> log4j.rootCategory=debug
> 
> log4j.category.console.cat = INFO
> log4j.category.com.jpmorgan.researchcontent.transmit.cat1.cat=WARN
> log4j.category.com.jpmorgan.researchcontent.transmit.cat2.cat=WARN
> log4j.category.com.jpmorgan.researchcontent.transmit.cat3.cat=WARN
> log4j.category.com.jpmorgan.researchcontent.transmit.cat4.cat=WARN
> 
> 
> 
> source code:
> 
> to create the default logging parameters
> static public void createCategory(String className) {
> 
>       PropertyConfigurator.configure(configFile);
> 
>       Category root = Category.getRoot();
> 
>       console = (TransmitCategory)TransmitCategory.getInstance("console");
>       console.addAppender(new FileAppender(new PatternLayout("%-5d %-5x
> Msg:
> %m%n"), System.out));
>       console.setPriority(org.apache.log4j.Priority.INFO);
>       console.setAdditivity(false);*/
> 
> 
>       cat = (TransmitCategory)TransmitCategory.getInstance(className);
>       try {
>            cat.addAppender(new FileAppender(layout, default, false));
>           cat.setPriority(org.apache.log4j.Priority.WARN);
>       } catch(IOException e) {e.printStackTrace();}
> 
>   }
> 
> 
> 
>  to add different categories
>  static public void appendToRoot(String system, String className, String
> filename) {
>       String filename = "";
> 
>     try {
> 
>         cat = (TransmitCategory)TransmitCategory.getInstance(className);
>         file = new FileAppender(layout, filename, true);
>         cat.addAppender(file);
>         cat.setPriority(org.apache.log4j.Priority.WARN);
>         } catch(ClassCastException e) {
>       e.printStackTrace();
>     }
>     catch(IOException e) {
>       e.printStackTrace();
>     }
> 
> 
> 
> This communication is for informational purposes only.  It is not intended
> as
> an offer or solicitation for the purchase or sale of any financial
> instrument
> or as an official confirmation of any transaction. All market prices, data
> and other information are not warranted as to completeness or accuracy and
> are subject to change without notice. Any comments or statements made
> herein
> do not necessarily reflect those of J.P. Morgan Chase & Co. Incorporated,
> its
> subsidiaries and affiliates.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to