Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Log4j - is it possible to log different message per appender?

807589Oct 1 2008 — edited Oct 1 2008
Hi folks,

I have three appenders(File, SMTP1, SMTP2) attached to a single logger. I want to log messages at all levels(INFO, WARN, ERROR, FATAL) into the File appender, (WARN, ERROR AND FATAL) to the SMTP1 appender for tech support team to receive email notification. Also, i want to log FATAL message to SMTP2, which send SMS to mobiles for a group of people from support team and the management.

Obviously, due to limited length of SMS messages, i dont want to include the same amount of details as what's sent to the email and log file on the server. I want to include a summary of it in the SMS message. The question is how do i configure/code the same logger to push different messages per appender? i.e. A method like
log.fatal("SMS", "FTP server timed out!!!"); //sms message for the business
log.fatal("email", "FPT server is timed out due to blah blah...stack trace as showing below......"); //more detailed email message
i know method like this does not exist in the current log4j API, i am just wondering if anyone alway known way of archieving something like this before i have to write any customised code. Many thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 29 2008
Added on Oct 1 2008
6 comments
512 views