1 14 15 package filesrv; 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 29 public class SetupLoggingHook implements InitServerHook { 30 private QuickServer quickserver; 31 32 public String info() { 33 return "Init Server Hook to setup logging."; 34 } 35 36 public void handleInit(QuickServer quickserver) throws Exception { 37 Logger logger = null; 38 FileHandler txtLog = null; 39 File log = new File("./log/"); 40 if(!log.canRead()) 41 log.mkdir(); 42 try { 43 logger = Logger.getLogger(""); 44 logger.setLevel(Level.FINEST); 45 46 logger = Logger.getLogger("org.quickserver"); 47 txtLog = new FileHandler("log/Filesrv_QuickServer%u%g.txt", 48 1024*1024, 20, true); 49 txtLog.setFormatter(new SimpleTextFormatter()); 50 txtLog.setLevel(Level.FINEST); 51 logger.addHandler(txtLog); 52 53 logger = Logger.getLogger("filesrv"); 54 txtLog = new FileHandler("log/FilesrvServer%u%g.txt", 55 1024*1024, 20, true); 56 txtLog.setFormatter(new SimpleTextFormatter()); 57 txtLog.setLevel(Level.FINEST); 58 logger.addHandler(txtLog); 59 60 quickserver.setAppLogger(logger); } catch(IOException e){ 62 System.err.println("Could not create txtLog FileHandler : "+e); 63 throw e; 64 } 65 } 66 } 67 | Popular Tags |