Skip to content

Instantly share code, notes, and snippets.

@sachin-handiekar
Created September 24, 2011 16:42
Show Gist options
  • Save sachin-handiekar/1239532 to your computer and use it in GitHub Desktop.
Save sachin-handiekar/1239532 to your computer and use it in GitHub Desktop.
log4j Basic Configurator
import com.foo.Bar;
// Import log4j classes.
import org.apache.log4j.Logger;
import org.apache.log4j.BasicConfigurator;
public class MyApp {
// Define a static logger variable so that it references the
// Logger instance named "MyApp".
static Logger logger = Logger.getLogger(MyApp.class);
public static void main(String[] args) {
// Set up a simple configuration that logs on the console.
BasicConfigurator.configure();
logger.info("Entering application.");
Bar bar = new Bar();
bar.doIt();
logger.info("Exiting application.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment