Hi All,

I took Jim Moore's suggestion in an old post to
implement dynamic subject for the smtpappender.  

(see
http://www.mail-archive.com/[email protected]/msg01246.html)

I found that gmail happens to be a very convenient
place to throw error level logs and gmail also groups
like subject headers together - so if an error throws
17 related log messages, gmail could group them
together for you.  But I couldn't get gmail to group
things properly with static subject headers so I
implemented a dynamic one.

I've attached the code in this message for anyone
interested.  Here are some things to note:
1. In it's current state, the code is at best a hack. 
2. It can be greatly improved from an efficiency
standpoint.  For instance, you could parse the subject
pattern in the activateoptions() method and never
parse it again.  Also, you could figure out in the
beginning if the person has put in any patterns at
all.
3. Also, it doesn't support '{}' attributes for stuff
like %c{1}, just %c.  
4. Also, made %d print out a non-standard date string
so it's easier to read for myself.

If anyone is interested, I'd be happy to implement
full pattern layout, clean up the code and make it
more efficient.  If not, at least the community can
find this hack in case they want dynamic subjects. 
The code works for log4j 1.2.9 and I also tested it on
jboss 3.2.3.  I did had to add a few classes in the
jboss log4j distribution that are missing from the
standard log4j 1.2.9 distribution (namely
.../log4j/jmx/* and .../log4j/or/jms).

I avoided using anything deprecated: made no mention
of the Category and Priority class.  A quick look at
the 1.3 alpha's smtpappender.java suggests that the
code should work properly in 1.3 as well.

If there is a better way to do this, please tell me,
I'd rather not have to inject my hack into log4j every
time there is a version change!

Feel free to email me if you you're too lazy to
compile it yourself.  


-Matthew Ma
Lightspoke - Free Web Based Database
http://www.lightspoke.com


=====
 Free Web-based Database Service 


                
__________________________________ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 

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

Reply via email to