I think you misunderstand the idea of level. Levels in log4j are things
like "DEBUG", "INFO", "WARN", "ERROR", "FATAL". So if your level is set
to INFO and in your call you execute logger.debug(message) - then the
message will be thrown away, because DEBUG < INFO. On the other hand if
you execute logger.info(message) - this message will be written to the
file, because INFO <= INFO.  

Several solutions come to mind:

        1) Create two loggers and make sure every call that contains
"SNMP" go to logger 1 and everything else to logger 2.

        2) Write everything to one file and use some log filtering tool
to view.

Finally, there may be a way to use Filters to re-direct, as I do not
have much experience with these, however I think this is just a finer -
grained mechanism to control what goes into the log file.

Cheers,
Philip.


-----Original Message-----
From: Praveen Kumar Hasthalapuram [mailto:[EMAIL PROTECTED] 
Sent: December 29, 2005 9:07 AM
To: [email protected]
Subject: Logging custom level using log4j in java


Hi All,
I need to log specified particular type of messages to one log file and
rest to another log file.

 For example say,  if message contains "SNMP" or "CDP" and so on, need
to log in to log1.log and rest of the messages need to log in to
log2.log

 How to configure the log4j.properties to log custom levels?

Is there any provision  to create custom levels and to configure it?

I heard that by Filters we can do this, It will be great if anyone throw
some light on this.

Thanks In Advacne,

Praveen

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

Reply via email to