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 ftpserver;
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: public class SetupLoggingHook implements InitServerHook {
25: private QuickServer quickserver;
26:
27: public String info() {
28: return "Init Server Hook to setup logging.";
29: }
30:
31: public void handleInit(QuickServer quickserver) throws Exception {
32: Logger logger = null;
33: FileHandler xmlLog = null;
34: File log = new File("./log/");
35: if (!log.canRead())
36: log.mkdir();
37: try {
38: logger = Logger.getLogger("");
39: logger.setLevel(Level.FINEST);
40:
41: logger = Logger.getLogger("org.quickserver.net.qsadmin");
42: xmlLog = new FileHandler("log/FtpServer_QSAdmin%u%g.xml",
43: 1024 * 1024, 20, true);
44: xmlLog.setLevel(Level.FINEST);
45: logger.addHandler(xmlLog);
46:
47: logger = Logger.getLogger("org.quickserver");
48: xmlLog = new FileHandler(
49: "log/FtpServer_QuickServer%u%g.xml", 1024 * 1024,
50: 20, true);
51: xmlLog.setLevel(Level.FINEST);
52: logger.addHandler(xmlLog);
53:
54: logger = Logger.getLogger("ftpserver");
55: xmlLog = new FileHandler("log/FtpServer%u%g.xml",
56: 1024 * 1024, 20, true);
57: xmlLog.setLevel(Level.FINEST);
58: logger.addHandler(xmlLog);
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: }
|