summaryrefslogtreecommitdiff
path: root/orktrack/src/net/sf/oreka/orktrack/LogManager.java
blob: 1c5be2742cc626a9fa0408c03213728bd7dd9917 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
 * Oreka -- A media capture and retrieval platform
 * 
 * Copyright (C) 2005, orecx LLC
 *
 * http://www.orecx.com
 *
 * This program is free software, distributed under the terms of
 * the GNU General Public License.
 * Please refer to http://www.gnu.org/copyleft/gpl.html
 *
 */

package net.sf.oreka.orktrack;

import java.io.File;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
 * This singleton class manages all application log4j loggers
 */
public class LogManager {

	static LogManager logManager = null;
	
	Logger rootLogger = null;
	Logger configLogger = null;
	Logger contextLogger = null;
	Logger portLogger = null;
	Logger userLogger = null;
	
	private LogManager() 
	{
		rootLogger = Logger.getRootLogger();
		rootLogger.setLevel(Level.INFO);
		configLogger = Logger.getLogger("config");
		contextLogger = Logger.getLogger("context");
		portLogger = Logger.getLogger("port");
		userLogger = Logger.getLogger("user");
		
	    BasicConfigurator.configure();	// in case there is no properties file
	}
	
	public static LogManager getInstance()
	{
		if (logManager == null)
		{
			logManager = new LogManager();
		}
		return logManager;
	}

	public void configure(String filename) {
		
		// Check wether filename is valid
		File file = new File(filename);
		if (file.exists()) {
			// Attempt to configure log4j
			PropertyConfigurator.configure(filename);
		}
		else {
			configLogger.warn("Log4j properties file does not exist:" + filename + " check your web.xml");
		}
	}
	
	/**
	 * @return Returns the rootLogger.
	 */
	public Logger getRootLogger() {
		return rootLogger;
	}
	

	/**
	 * @param rootLogger The rootLogger to set.
	 */
	public void setRootLogger(Logger rootLogger) {
		this.rootLogger = rootLogger;
	}

	/**
	 * @return Returns the configLogger.
	 */
	public Logger getConfigLogger() {
		return configLogger;
	}
	

	/**
	 * @param configLogger The configLogger to set.
	 */
	public void setConfigLogger(Logger configLogger) {
		this.configLogger = configLogger;
	}

	public Logger getContextLogger() {
		return contextLogger;
	}

	public void setContextLogger(Logger contextLogger) {
		this.contextLogger = contextLogger;
	}

	public Logger getPortLogger() {
		return portLogger;
	}

	public void setPortLogger(Logger portLogger) {
		this.portLogger = portLogger;
	}

	public Logger getUserLogger() {
		return userLogger;
	}

	public void setUserLogger(Logger userLogger) {
		this.userLogger = userLogger;
	}
	
	

}