blob: 40691001ed5187c3a9519381a59aee3fa591f163 (
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
|
/*
* 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.orkweb;
import java.io.File;
import org.apache.log4j.BasicConfigurator;
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;
private LogManager()
{
rootLogger = Logger.getRootLogger();
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 {
rootLogger.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;
}
}
|