1 16 17 18 package org.apache.log4j.net.test; 19 20 import org.apache.log4j.Logger; 21 import org.apache.log4j.PropertyConfigurator; 22 import org.apache.log4j.Priority; 23 import org.apache.log4j.NDC; 24 25 26 public class SyslogMin { 27 28 static Logger CAT = Logger.getLogger(SyslogMin.class); 29 30 public 31 static 32 void main(String argv[]) { 33 34 if(argv.length == 1) { 35 ProgramInit(argv[0]); 36 } 37 else { 38 Usage("Wrong number of arguments."); 39 } 40 test("someHost"); 41 } 42 43 44 static 45 void Usage(String msg) { 46 System.err.println(msg); 47 System.err.println( "Usage: java " + SyslogMin.class + " configFile"); 48 System.exit(1); 49 } 50 51 52 static 53 void ProgramInit(String configFile) { 54 int port = 0; 55 PropertyConfigurator.configure(configFile); 56 } 57 58 static 59 void test(String host) { 60 NDC.push(host); 61 int i = 0; 62 CAT.debug( "Message " + i++); 63 CAT.info( "Message " + i++); 64 CAT.warn( "Message " + i++); 65 CAT.error( "Message " + i++); 66 CAT.log(Priority.FATAL, "Message " + i++); 67 CAT.debug("Message " + i++, new Exception ("Just testing.")); 68 } 69 } 70 | Popular Tags |