Loggly

Close

If you don't know the subdomain for your account, you can retrieve it by resetting your password. If you don't have an account, signup now.

Blog / Article

Java logging, and our awesome community

Posted 20 Sep, 2011 by jon@loggly.com in Code and Log Management

Since I'm on a roll with the blog posts, I thought I'd quickly cover some of the ways you can log out of your Java code to us. I've been buried in *our* java code for nearly two years now, and we've been talking about improving the quality of the logging that we're doing there recently. As it turns out, there are some pretty interesting projects out there that look like they may be just what we need...

Before talking about them, though, I thought I'd give you a quick run-down on how we're doing things now. We use a very slightly tweaked version of the log4j SyslogAppender  (version 1.2.16) - the tweak is that we upped the message size from 1k to 32k. Yep, we're completely ignoring the syslog RFC, but its been working perfectly fine for us for quite a while, so I'm ok with that. We configure log4j as described on our wiki so that we log to a local syslog-ng (using a different facility for each app) which forwards to the appropriate ports on logs.loggly.com. Its a very simple approach, but has been very reliable for us.

So why would we want to change it?

The main reason is that we set this up before we could send JSON data, and we log a lot of performance data, which is a perfect fit for JSON. We're going to be moving all of our java logging to JSON over the next few months, because it will let us dive deeper into our logs, without all the noise.

A couple of weeks ago, Patrick Lightbody from neustar emailed us to tell us about a java class he'd written to send data into Loggly using http. Its an extension of java.util.logging.Handler and is only a couple of hundred lines of nice clean code . He shared it on github and described how to use it in his email.

 
If you're using java.util.logging, give it a whirl!

 

This got me thinking that we've been a little, um, remiss in communicating just how many libraries people have written for us, so I did a search on github for java projects with loggly in the repo name and found some other projects that also look pretty nice...

All of these projects use our HTTP interface, rather than TCP or UDP, which makes sense since we don't currently support JSON except over HTTP. We're planning on fixing that :-)

Expanding the search a little, there are a bunch of projects in github, on top of the ones we've created, that should make it easy to log out of javascript, python, ruby, and C#, as well as the Java stuff I talked about above.

We're obviously pretty happy that so many people are working on making it easier to get data to us, and I want to say thank you to everyone who has been contributing to all of those projects.  I'd like to encourage all of you reading this to jump in and help out if you can. Everyone who is contributing to these projects should drop us a line, and we'll send you one of our X-Ray Beaver tee's as a thank you :-)

  • Joshua

    Joshua 22 Oct, 2011 03:35am

    I forked Spidertracks’ excellent log4j appender and added some additional features, mostly graceful shutdowns and guaranteed delivery of all messages, assuming you notify log4j you are shutting your application down.

    You can get the extended code here for the time being, although I hope Spidertracks will pull the changes to his version of the code:

    https://github.com/jbcpollak/logglylog4j

  • Core Java Interview Answers

    Core Java Interview Answers 7 Feb, 2012 12:32am

    Logging is still a underused feature and your tips are fantastic specially having log templates in Eclipse makes job much easier.
    Another one you can include is using correct level of logging for message specially logging incoming message and outgoing message on INFO level if you are dealing with upstream and downStream systems. you may like Java logging best practices

  • Yegor

    Yegor 2 Nov, 2012 11:04am

    Check this out: http://www.rexsl.com/rexsl-core/log.html. This appender does exactly what you need for Java-to-Loggly

  • Roshan

    Roshan 6 Feb, 2013 02:51pm

    Is anyone else using the Rexsl appender? Interested in hearing your feedback on it. We love loggly and would like an easy solution like the rexsl log appender to use in our Java application.

Share Your Thoughts

Blog Categories

Search

Loading

Archives by Month