Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Log4J too many files

Log4J too many files

Log4J too many files

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());




                                    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);


                                                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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close