01: /*
02: * This file is part of the QuickServer library
03: * Copyright (C) 2003-2005 QuickServer.org
04: *
05: * Use, modification, copying and distribution of this software is subject to
06: * the terms and conditions of the GNU Lesser General Public License.
07: * You should have received a copy of the GNU LGP License along with this
08: * library; if not, you can download a copy from <http://www.quickserver.org/>.
09: *
10: * For questions, suggestions, bug-reports, enhancement-requests etc.
11: * visit http://www.quickserver.org
12: *
13: */
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(
51: "log/EchoServer_QuickServer%u%g.txt", 1024 * 1024,
52: 20, true);
53: txtLog.setFormatter(new SimpleTextFormatter());
54: txtLog.setLevel(Level.FINEST);
55: logger.addHandler(txtLog);
56:
57: logger = Logger.getLogger("echoserver");
58: txtLog = new FileHandler("log/EchoServer%u%g.txt",
59: 1024 * 1024, 20, true);
60: txtLog.setFormatter(new SimpleTextFormatter());
61: txtLog.setLevel(Level.FINEST);
62: logger.addHandler(txtLog);
63:
64: quickserver.setAppLogger(logger); //img
65:
66: //debug non-blocking mode
67: //quickserver.debugNonBlockingMode(false);
68: } catch (IOException e) {
69: System.err.println("Could not create txtLog FileHandler : "
70: + e);
71: throw e;
72: }
73: }
74: }
|