On Apr 19, 2006, at 11:03 PM, Meera Mehta wrote:
Thanks for reply James.
Let me make you more clear.
I want Separate Level SQL and i want to enable/disable
it with Flag(isSQLEnable),regardless of current
Priority.
I dont have any code level access to my
application.(As i mensioned we are using commons
logging extension)so i can not create separate logger
in the code.
if i create separate logger in properties file with
name say
log4j.logger.SQL=SQL,<Appender list...>
..........
will it log request(with SQL Level)coming from any
package(say my package is com.app.test will it accepts
SQL log request generated from this package also)??
Hope so i am able to make you more clear!!!
Thanks in advance.
First, let me reemphasize what others have said: you are trying to
make Level do what Logger is designed to do and does well. The idea
behind a hierarchy of loggers is to allow you to organize messages by
a topic (usually the class where the logging request originated) and
then control the processing of those messages. Since almost all the
examples use class names for logger (topic) names, many people assume
that logger names must be class names.
You state that "you do not have code level access". If you aren't
able to change the code, how would you add logging requests that used
your proposed new level? If you can write new logging calls, then
you can introduce new loggers.
As a start, I'd suggest something along the line of:
public class SomeClass {
//
// standard diagnostic logger
private static final Logger logger = Logger.getLogger
(SomeClass.class);
//
// a distinct logger for database related logging (could be
just called sql or "sql." + class name
private static final Logger sqlLogger = Logger.getLogger
("sql.com.example.myapp.SomeClass");
public void store() {
logger.debug("storing instance to database");
sqlLogger.info(sqlStatement);
}
}
If you wanted to turn off all loggers that start with "sql.", then
you could execute:
Logger.getLogger("sql").setLevel(Level.OFF);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]