Log4J Twitter Appender - twitter your logmessages :)

Markus Eisele
0
Don't ask me why, but I was thinking about a "twittering" WebLogic for some days now. And I finaly managed to spend some minutes on this today. This is the first approach. Have some more in mind and would like to contribute them, too.

Let's start over with the Log4JTwitterAppender:
You can download the jar directly. Anything else you need is a recent version of Log4J and JTwitter. I used Log4J 1.2.15 and JTwitter 1.2. Now drop all three jars log4j-1.2.15.jar, jtwitter.jar and l4jtwitterappender.jar to your project and add a log4j.properties file to it.

A sample log4j.properties looks like this:

# Add the twitter appender
log4j.rootLogger=DEBUG, TWITTER
log4j.appender.TWITTER=
net.eisele.log4j.twitterappender.TwitterAppender
log4j.appender.TWITTER.Username=
>your_twitter_username<
log4j.appender.TWITTER.Password=
>your_twitter_password<
log4j.appender.TWITTER.ProxyPort=
>proxy_port<
log4j.appender.TWITTER.ProxyHost=
>proxy_host<
log4j.appender.TWITTER.layout=
org.apache.log4j.PatternLayout
log4j.appender.TWITTER.layout.ConversionPattern=
[%d{MMM dd HH:mm:ss}] %-5p (%.20F) - %.49m%n


If everything is configured, you can start logging:


private static final Logger log =
Logger.getLogger("your.Clazzname");

log.debug("your log message");


If everything works fine, you now have a logging twitter account :)



You can configure the layout if you like with the normal PatternLayout machanism. But to be honest ... 140 characters are hardly enough for log messages :)
Anyway, it was fun doing it ...

Post a Comment

0Comments

Post a Comment (0)