kirankanukuntla
Programmer
Hi I am using Log4j.
I have created one utility class which I use in other classes to get the logger.
public class CommonLogger {
private static Logger logur;
private TimeLogger() {
}
private static Logger Logur(String className) {
Configuration configur = null;
//default values for logging
String pattern = null, logFile = null, level = null;
try {
configur = new PropertiesConfiguration("/WEB-INF/Time.properties");
pattern = configur.getString("Log4j.pattern");
logFile = configur.getString("Log4J.path.logFile");
level = configur.getString("Log4J.level").toUpperCase();
logur = Logger.getLogger(className);
PatternLayout patternLayout = new PatternLayout(pattern);
FileAppender appender = null;
try {
appender = new FileAppender(patternLayout, logFile, true);
} catch (IOException ioe) {
System.out.println("Exception in class="+ className+" method="+"Logur"
+ " " + ioe.getMessage());
}
logur.addAppender(appender);
if ("INFO".equals(level))
logur.setLevel((Level) Level.INFO);
else if ("DEBUG".equals(level))
logur.setLevel((Level) Level.DEBUG);
else if ("ERROR".equals(level))
logur.setLevel((Level) Level.ERROR);
else if ("FATAL".equals(level))
logur.setLevel((Level) Level.FATAL);
else if ("TRACE".equals(level))
logur.setLevel((Level) Level.TRACE);
else if ("WARN".equals(level))
logur.setLevel((Level) Level.WARN);
else
logur.setLevel((Level) Level.INFO);
} catch (ConfigurationException ce) {
System.out.println("ConfigurationException in class=" + className+" method="
+ "Logur. " + ce.getMessage());
}
return logur;
}
public static Logger getLogger(String className) {
logur = Logur(className);
return logur;
}
}
I use this class in other classes to get logger like,
Logger logger = CommonLogger.getLogger(SomeDao.class.getName());
Its opening too many file descriptors and giving me the message too many files open.
I dont know how to limit number of open file descriptors.
What mistake am i doing
Any light on this?
Thanks in advance.
I have created one utility class which I use in other classes to get the logger.
public class CommonLogger {
private static Logger logur;
private TimeLogger() {
}
private static Logger Logur(String className) {
Configuration configur = null;
//default values for logging
String pattern = null, logFile = null, level = null;
try {
configur = new PropertiesConfiguration("/WEB-INF/Time.properties");
pattern = configur.getString("Log4j.pattern");
logFile = configur.getString("Log4J.path.logFile");
level = configur.getString("Log4J.level").toUpperCase();
logur = Logger.getLogger(className);
PatternLayout patternLayout = new PatternLayout(pattern);
FileAppender appender = null;
try {
appender = new FileAppender(patternLayout, logFile, true);
} catch (IOException ioe) {
System.out.println("Exception in class="+ className+" method="+"Logur"
+ " " + ioe.getMessage());
}
logur.addAppender(appender);
if ("INFO".equals(level))
logur.setLevel((Level) Level.INFO);
else if ("DEBUG".equals(level))
logur.setLevel((Level) Level.DEBUG);
else if ("ERROR".equals(level))
logur.setLevel((Level) Level.ERROR);
else if ("FATAL".equals(level))
logur.setLevel((Level) Level.FATAL);
else if ("TRACE".equals(level))
logur.setLevel((Level) Level.TRACE);
else if ("WARN".equals(level))
logur.setLevel((Level) Level.WARN);
else
logur.setLevel((Level) Level.INFO);
} catch (ConfigurationException ce) {
System.out.println("ConfigurationException in class=" + className+" method="
+ "Logur. " + ce.getMessage());
}
return logur;
}
public static Logger getLogger(String className) {
logur = Logur(className);
return logur;
}
}
I use this class in other classes to get logger like,
Logger logger = CommonLogger.getLogger(SomeDao.class.getName());
Its opening too many file descriptors and giving me the message too many files open.
I dont know how to limit number of open file descriptors.
What mistake am i doing
Any light on this?
Thanks in advance.