Introducing Log4Go: Logging for Google Go

When working on my last project, I wanted an easy way to perform logging. I had difficulty finding a logging framework that worked for me, and I figured it would be another good small project if I were to write a log4j-like logger for Google Go.

Here's how to install Log4go:

GOPATH=`pwd` go get # Beginners
go get # Nerds

The latter example assumes that you have the environment variable $GOPATH set. When $GOPATH is set, any packages that are installed will go into a directory hierarchy under that directory. I recommend $HOME/golibs/ as a value for testing and development.

Here's sample usage of Log4go:

import log ""
func main() {

And the output might look something like this:

[301.119ms] INFO: foobar

I wrote some sample tests for Log4go. Here's how to run them:

go test ./src/

And if the test passes, the output should look like this:

ok       0.009s

The source can be downloaded from GitHub:

git clone git://

This project wasn't too terribly complicated, but it gave me some new techniques to try in Google Go. My next project promises to be much more complicated and interesting. Until then, feel free to like, comment, rate, flame or whatever. Smiling

Average: 3 (7 votes)
Your rating: None