On Dec 21, 2005, at 2:50 AM, Joseph, Shinoy wrote:
Hi Arnold,
Thank you very much for your reply.
Let me explain our requirement. Our system communicates to the
external systems for storing and rerieving data. This data has got
its own format and all. During development and Testing or even
production our developers need to control the data logging out. So
we decided to have a seperate level of log, without affecting the
defualt levels of log4j. Essencially we need to have a log level
which is to be turned off and on, doesn't matter whether the
defualt levels are enabled or not.
Also we don't want to create new branch out of log4j for this. If
we can accomplish it with adding some new tag/attributes to the
log4j.xml or some thing like that and use that attribute in the new
Logger class (thats what I am trying to implement)
That seems exactly where you would want to use a branch in the
hierarchy of loggers. It seems you have two audiences for the log
requests, those log requests intended to diagnosticians who are
trying to understand the behavior of the system to figure out what is
going on so they may fix a problem and this external system. To
address this, split your hierarchy into two branches, for example,
all loggers that start with "external" are directed to the external
system and everything else is a diagnostic log message. So in your
classes, you'd could have something like:
class Foo {
// diagnostic logger
private static Logger logger = Logger.getLogger(Foo.class);
// external system logger
private static Logger externalLogger = Logger.getLogger
("external." + Foo.class);
..
}
If you configuration file, you could use:
log4j.logger.external=OFF
log4j.rootLogger=DEBUG, CON
to disable logging on the external system and have everything else
DEBUG and higher sent to the CON appender. Or:
log4j.logger.external=INFO, EXTERNAL_SYSTEM
log4j.additivity.external=false
log4j.rootLogger=INFO,CON
to have everything INFO and higher from the external branch of the
logger hierarchy to be directed the EXTERNAL_SYSTEM appender (and not
fall through to the CON appender) and everything else INFO and higher
go to the console.
Obviously, you could pick a better name than "external" and there may
not be a need to subdivide external like I did by appending the class
name.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]