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 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: /**
26: * FileServer Example
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("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); //img
61: } catch (IOException e) {
62: System.err.println("Could not create txtLog FileHandler : "
63: + e);
64: throw e;
65: }
66: }
67: }
|