First download the bag required by log4, not much. Write a program to run. There are not many principles, there are many online. Package Untitled9;
Import org.apache.log4j. *;
Public class testlog4j {static logger log = logger.getlogger (Testlog4j.class.getname ()); public static void main (string args []) {BasicConfigurator.configure (); // logging Various methods log.debug (" Start of main () "); log.info (" Just Testing a log message with priority set to info "); Log.Warn (" Just Testing a log message with priority set to warn "); log.error (" Just Testing a log message with prior set to error "); Log.FATAL (" Just Testing A Log Message with Priority Set To Fatal "); // Another inconvenient format log.log (Priority.debug," Testing A Log Message Use a alternate form "); log.debug (" end of main (). ");}}