Entries Tagged as 'logging'

Monday, December 29th, 2008

Regular Expression to Replace System.out.println with Log4j

This is nothing fancy, but may help some of you log4j newbies.
I found myself replacing a project's hideous System.out.println statements with log4j log calls.
Just do a File Search in eclipse , tick the regular expression box and do a Replace:

Find: System\.out\.println\("(.+?)"\);
Replace: log.info("\1");

Now you just have to go in and add your imports and your log [...]

Friday, February 15th, 2008

Limiting log4j SMTPAppender

I wanted to set a maximum amount of e-mails that SMTPAppender would send after filling up a mailbox with 30,000 damn e-mails.
Turns out it was pretty damn easy, I set up my appender in a java class, and the SMTP appender has a method called setEvaluator that takes an instance of TriggeringEventEvaluator, so I just [...]