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