01: package net.sourceforge.squirrel_sql.client;
02:
03: /*
04: * Copyright (C) 2001-2006 Colin Bell
05: * colbell@users.sourceforge.net
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: */
21: import java.io.IOException;
22: import java.util.Calendar;
23: import java.util.Date;
24: import java.text.DateFormat;
25:
26: import org.apache.log4j.BasicConfigurator;
27: import org.apache.log4j.Category;
28: import org.apache.log4j.PropertyConfigurator;
29:
30: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
31: import net.sourceforge.squirrel_sql.fw.util.log.Log4jLoggerFactory;
32:
33: public class SquirrelLoggerFactory extends Log4jLoggerFactory {
34: public SquirrelLoggerFactory() throws IllegalArgumentException {
35: super (false);
36: String configFileName = ApplicationArguments.getInstance()
37: .getLoggingConfigFileName();
38: if (configFileName != null) {
39: PropertyConfigurator.configure(configFileName);
40: } else {
41: Category.getRoot().removeAllAppenders();
42: try {
43: // final String logFileName = new ApplicationFiles().getExecutionLogFile().getPath();
44: // final PatternLayout layout = new PatternLayout("%-4r [%t] %-5p %c %x - %m%n");
45: // FileAppender fa = new FileAppender(layout, logFileName);
46: // fa.setFile(logFileName);
47: SquirrelAppender fa = new SquirrelAppender();
48:
49: BasicConfigurator.configure(fa);
50: final ILogger log = createLogger(getClass());
51: log
52: .info("No logger configuration file passed on command line arguments. Using default log file: "
53: + fa.getFile());
54: } catch (IOException ex) {
55: final ILogger log = createLogger(getClass());
56: log
57: .error(
58: "Error occured configuring logging. Now logging to standard output",
59: ex);
60: BasicConfigurator.configure();
61: }
62: }
63: doStartupLogging();
64: }
65:
66: private void doStartupLogging() {
67: final ILogger log = createLogger(getClass());
68: log
69: .info("#############################################################################################################");
70: log.info("# Starting " + Version.getVersion() + " at "
71: + DateFormat.getInstance().format(new Date()));
72: log
73: .info("#############################################################################################################");
74: log.info(Version.getVersion() + " started: "
75: + Calendar.getInstance().getTime());
76: log.info(Version.getCopyrightStatement());
77: log.info("java.vendor: " + System.getProperty("java.vendor"));
78: log.info("java.version: " + System.getProperty("java.version"));
79: log.info("java.runtime.name: "
80: + System.getProperty("java.runtime.name"));
81: log.info("os.name: " + System.getProperty("os.name"));
82: log.info("os.version: " + System.getProperty("os.version"));
83: log.info("os.arch: " + System.getProperty("os.arch"));
84: log.info("user.dir: " + System.getProperty("user.dir"));
85: log.info("user.home: " + System.getProperty("user.home"));
86: log.info("java.home: " + System.getProperty("java.home"));
87: log.info("java.class.path: "
88: + System.getProperty("java.class.path"));
89: }
90: }
|