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 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: /**
25: * SetupLoggingHook
26: * @author Akshathkumar Shetty
27: */
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(
47: "log/EchoWebServer_QuickServer%u%g.txt",
48: 1024 * 1024, 20, true);
49: txtLog.setFormatter(new SimpleTextFormatter());
50: txtLog.setLevel(Level.FINE);
51: logger.addHandler(txtLog);
52:
53: logger = Logger.getLogger("");
54: txtLog = new FileHandler("log/EchoWebServer_Full%u%g.txt",
55: 1024 * 1024, 20, true);
56: txtLog.setFormatter(new SimpleTextFormatter());
57: txtLog.setLevel(Level.FINEST);
58: logger.addHandler(txtLog);
59:
60: logger = Logger.getLogger("echowebserver");
61: txtLog = new FileHandler("log/EchoWebServer%u%g.txt",
62: 1024 * 1024, 20, true);
63: txtLog.setFormatter(new SimpleTextFormatter());
64: txtLog.setLevel(Level.FINE);
65: logger.addHandler(txtLog);
66:
67: quickserver.setAppLogger(logger);//img
68: } catch (IOException e) {
69: System.err.println("Could not create txtLog FileHandler : "
70: + e);
71: throw e;
72: }
73: }
74: }
|