File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes Log4J Debug levels and over-riding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Log4J Debug levels and over-riding" Watch "Log4J Debug levels and over-riding" New topic

Log4J Debug levels and over-riding

Greg Ostravich
Ranch Hand

Joined: Jul 11, 2002
Posts: 112
Update:I continued to play with it and it appears the levels I'm setting from the Properties file are not working. It doesn't appear to have to do with 'over-riding' the values of the root logger. The properties file is working for the Log4J settings (such as PatternLayout), but not for my "HRUpdates.INNER" log.

Any clues are still appreciated.

==== original post ====
I'm using the example Log4J program in my own code.
In it, they create different loggers.
I'm using one called 'LOG' and one called 'INNER' for my code.
The 'INNER' log is used for iterations and I don't always want it turned on.

My question has to do with how the log levels are set from a Property file. In the Log4J example program, they set the log levels in a property file.
I tried to do the same but am running into a problem with the root logger over-riding the levels for a specific logger. In this case I'm setting the root logger to DEBUG and in the property file setting my INNER log to a higher level so I don't see the messages. It doesn't work and I still see the INNER log messages even though I set the level to something else.
Is there a way to over-ride the root level in the other logger from the property file and I'm just doing it wrong? If I call 'setLevel' directly in the code for that logger it works fine. I am able to read in my property file correctly because any changes to the root logger property are affecting my output.

Thinking I had the levels reversed or something, I just tried setting the root logger to ERROR and over-riding the LOG logger with DEBUG but that didn't work either.

Here's the relevant portion of my property file:

In the example they specify the class like this:

In this particular project my jar is just HRUpdates so I don't think it's the level I qualified the class where the logger is but any clues you can provide are appreciated.

Here's the code where I create my logs:

If I need to RTFM better please let me know by pointing me to the right manual. I've checked some of the links off the Log4J page, including this one that includes the log level hierarchy, and they were pretty good but I didn't see any that mentioned what I might be doing wrong.
[ July 14, 2005: Message edited by: Greg Ostravich ]

Greg Ostravich - SCPJ2
Carol Enderlin
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
In the example you show the package is org.apache.log4j.examples. Your package is HRUpdates, so your configuration is missing the prefix "log4j.logger.". So try:


# For INNER loops - change level to DEBUG to see inner loops.

In the example they specify the class like this:

[ July 14, 2005: Message edited by: Carol Enderlin ]
Greg Ostravich
Ranch Hand

Joined: Jul 11, 2002
Posts: 112
Thank you, thank you, thank you, thank you, thank you.

Did I say thank you?

It works great! Thanks for the clue.

Was the problem that when the factory created my INNER log it doesn't really reside in HRUpdates but in fact resides in the scope of the Log4J class I'm using which is why my qualification didn't resolve to the correct object?

Am I explaining this very well?

Thanks again for your help.
[ July 15, 2005: Message edited by: Greg Ostravich ]
I agree. Here's the link:
subject: Log4J Debug levels and over-riding
jQuery in Action, 3rd edition