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