You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by rubble <mc...@yahoo.com> on 2004/12/26 07:52:17 UTC

dynamic subject for smtpappender log4j pattern

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/log4j-user@jakarta.apache.org/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 
 


Re: dynamic subject for smtpappender log4j pattern

Posted by "Kevin A. Burton" <bu...@newsmonster.org>.
rubble wrote:

>Hi Kevin,
>
>Haven't checked the cvs :-).  I just checked the
>distribution, didn't find it and then figured it was
>faster for me to code the 20 lines.  
>
>Besides, my log4j needs to work inside jboss and I
>didn't want to have to test the stuff in cvs for
>compatability.
>
>So does this mean log4j will have dynamic subject
>enabled in future releases?  I'll take a look at the
>cvs smtpappender later if I need to mess with my code.
>
Well it looks that way. I certainly want it!

> 
>
>On another note, would you happen to have a Rojo
>invite?  Would like to try it myself.
>  
>
I'll send you one........

-- 

Use Rojo (RSS/Atom aggregator).  Visit http://rojo.com. Ask me for an 
invite!  Also see irc.freenode.net #rojo if you want to chat.

Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html

If you're interested in RSS, Weblogs, Social Networking, etc... then you 
should work for Rojo!  If you recommend someone and we hire them you'll 
get a free iPod!
    
Kevin A. Burton, Location - San Francisco, CA
       AIM/YIM - sfburtonator,  Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: dynamic subject for smtpappender log4j pattern

Posted by rubble <mc...@yahoo.com>.
Hi Kevin,

Haven't checked the cvs :-).  I just checked the
distribution, didn't find it and then figured it was
faster for me to code the 20 lines.  

Besides, my log4j needs to work inside jboss and I
didn't want to have to test the stuff in cvs for
compatability.

So does this mean log4j will have dynamic subject
enabled in future releases?  I'll take a look at the
cvs smtpappender later if I need to mess with my code.
 

On another note, would you happen to have a Rojo
invite?  Would like to try it myself.

Thanks for the info.  

-Matthew

--- "Kevin A. Burton" <bu...@newsmonster.org> wrote:

> rubble wrote:
> 
> >Hi All,
> >
> >I took Jim Moore's suggestion in an old post to
> >implement dynamic subject for the smtpappender.  
> >  
> >
> How is this different than whats already implemented
> in CVS?  The 
> SMTPAppender in CVS now supports a pattern in the
> subject...
> 
> Kevin
> 
> -- 
> 
> Use Rojo (RSS/Atom aggregator).  Visit
> http://rojo.com. Ask me for an 
> invite!  Also see irc.freenode.net #rojo if you want
> to chat.
> 
> Rojo is Hiring! -
> http://www.rojonetworks.com/JobsAtRojo.html
> 
> If you're interested in RSS, Weblogs, Social
> Networking, etc... then you 
> should work for Rojo!  If you recommend someone and
> we hire them you'll 
> get a free iPod!
>     
> Kevin A. Burton, Location - San Francisco, CA
>        AIM/YIM - sfburtonator,  Web -
> http://peerfear.org/
> GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D
> 8D04 99F1 4412
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail:
> log4j-user-help@logging.apache.org
> 
> 


=====
 Free Web-based Database Service 


		
__________________________________ 
Do you Yahoo!? 
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: dynamic subject for smtpappender log4j pattern

Posted by "Kevin A. Burton" <bu...@newsmonster.org>.
rubble wrote:

>Hi All,
>
>I took Jim Moore's suggestion in an old post to
>implement dynamic subject for the smtpappender.  
>  
>
How is this different than whats already implemented in CVS?  The 
SMTPAppender in CVS now supports a pattern in the subject...

Kevin

-- 

Use Rojo (RSS/Atom aggregator).  Visit http://rojo.com. Ask me for an 
invite!  Also see irc.freenode.net #rojo if you want to chat.

Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html

If you're interested in RSS, Weblogs, Social Networking, etc... then you 
should work for Rojo!  If you recommend someone and we hire them you'll 
get a free iPod!
    
Kevin A. Burton, Location - San Francisco, CA
       AIM/YIM - sfburtonator,  Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org