1 14 15 package echoserver; 16 17 import org.quickserver.net.server.*; 18 import org.quickserver.net.InitServerHook; 19 20 import java.io.*; 21 22 import org.quickserver.util.logging.*; 23 import java.util.logging.*; 24 25 public class SetupLoggingHook implements InitServerHook { 26 private QuickServer quickserver; 27 28 public String info() { 29 return "Init Server Hook to setup logging."; 30 } 31 32 public void handleInit(QuickServer quickserver) throws Exception { 33 Logger logger = null; 34 FileHandler txtLog = null; 35 File log = new File("./log/"); 36 if(!log.canRead()) 37 log.mkdir(); 38 try { 39 logger = Logger.getLogger(""); 40 logger.setLevel(Level.FINEST); 41 42 logger = Logger.getLogger(""); 43 txtLog = new FileHandler("log/EchoServer_Full%u%g.txt", 44 1024*1024, 5, true); 45 txtLog.setFormatter(new SimpleTextFormatter()); 46 txtLog.setLevel(Level.FINEST); 47 logger.addHandler(txtLog); 48 49 logger = Logger.getLogger("org.quickserver"); 50 txtLog = new FileHandler("log/EchoServer_QuickServer%u%g.txt", 51 1024*1024, 20, true); 52 txtLog.setFormatter(new SimpleTextFormatter()); 53 txtLog.setLevel(Level.FINEST); 54 logger.addHandler(txtLog); 55 56 logger = Logger.getLogger("echoserver"); 57 txtLog = new FileHandler("log/EchoServer%u%g.txt", 58 1024*1024, 20, true); 59 txtLog.setFormatter(new SimpleTextFormatter()); 60 txtLog.setLevel(Level.FINEST); 61 logger.addHandler(txtLog); 62 63 quickserver.setAppLogger(logger); 65 } catch(IOException e){ 68 System.err.println("Could not create txtLog FileHandler : "+e); 69 throw e; 70 } 71 } 72 } 73 | Popular Tags |