Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3304476
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:03:57+00:00 2026-05-17T21:03:57+00:00

Historical Context: This problem ended up being not at all what I thought it

  • 0

Historical Context: This problem ended up being not at all what I thought it was. The cause and solution are below, but the original posting is left for reference.

I’m developing a simple framework for periodically polling a directory for .properties files, then performing SQL queries and sending e-mails based on their configurations. Because each .properties file has the same spectrum of operations, they are all interpreted by the same Task class. But since they each represent different logical operations, they each get separate log files.

This is accomplished by sharing one instance of a log4j RollingFileAppender, and dynamically changing its output file based on a value in the .properties file. Since this is a single-threaded application, this works fine.

However, I’ve noticed that in certain situations, this RollingFileAppender will become closed, and the application will continue on obliviously except that now no logging takes place. I’ve only managed to catch this in action once, thanks to the console output, since usually this service is running as a background process on a Linux server. Here’s what happened:

1) StartScheduler, the main class, creates a new instance of TaskPoller every minute.

2) TaskPoller scans the directory, loads a little information from each .properties file, and determines if it should be run. It also has its own separate RollingFileAppender, which it retrieves via Logger.getLogger(TaskPoller.class). If a Task should be run, then it instantiates a Task object, passing in the specific .properties file to be run.

3) Task gets its RollingFileAppender, then calls fileAppender.setFile(“newtaskname.log”) and fileAppender.activateOptions() to change the output file location. Then, during its execution, something like this happens:

[TaskPoller]
...
task = new Task(fileName); //Points RollingFileAppender to the right place
if (!task.Execute())
    logger.warn(fileName + " returned with an error code."); //Succeeds
[Task.Execute]
...
try {
    dbDAO.Connect();
} catch (Exception e) {
    logger.fatal{"Database connection error.", e}; //Different RFA; Fails
    return false;
}
[DBDAO.Connect throws SQLException, ClassNotFoundException]
...
try {
    Class.forName(dbDriver); //Dynamically loaded jdbc driver class name
    connection = DriverManager.getConnection(urlString, userName, password);
} catch (SQLException e) {
    if (connection != null)
        try { connection.close(); } catch (Exception e2) { ; }
    throw e;
}

What’s happening is that during DBDAO.Connect(), sometimes I’ll get a com.mysql.jdbc.exceptions.jdbc4.CommunicationsException (or some other unexpected exception from whichever jdbc class is loaded). This will not be caught by Connect(), but it will be caught by Execute().

Somehow, this process causes Task’s RollingFileAppender to become closed. The only thing I can think of that’s special to this situation, as opposed to its consistent and stable normal operation, is that the exception being thrown isn’t declared as thrown by Connect(). But I don’t think that should cause a log4j Appender to close.

So my question is, what could be causing this appender to unexpectedly close in methods that have nothing to do with its configuration?

–Edit–
It looks like I’ve been misdirected entirely; the problem is somewhere in the interactions between Quartz, which I was using to have TaskPoller fire every minute, and log4j. I don’t entirely understand its cause yet, but [this solution][1] seems to solve this problem. It just didn’t manifest itself as an observed problem until now, so I thought it had something to do with what was happening recently.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:03:58+00:00Added an answer on May 17, 2026 at 9:03 pm

    The real cause of this problem is an interaction between the Quartz scheduler and the way I was using log4j. It turns out, if you modify log4j’s properties (which I was doing by calling fileAppender.setFile(fileName) and fileAppender.activateOptions()) on a Quartz worker thread (even if Quartz is configured to only have a single thread running at a time), things break down. This is fixed by reloading the log4j properties on each new instance of the worker thread before using it, which I accomplished like so:

    [Task() Constructor]
    Properties props = new Properties();
    URL url = ClassLoader.getSystemResource("log4j.properties");
    try {
        props.load(url.openStream());
        PropertyConfigurator.configure(props);
    } catch (Exception e) {
        //The logger that never got renamed never stopped working.
        Logger.getLogger(TaskPoller.class).error("Diagnostics!");
    }
    logger = Logger.getLogger(Task.class);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question exists because it has historical significance, but it is not considered a
This is a(n) historical question, not a comparison-between-languages question: This article from 2005 talks
I suppose there could be historical reasons for this naming and that other languages
I need to create a historical timeline starting from 1600's to the present day.
I'd like to view historical data for guest cpu/memory/IO usage, rather than just current
We have some integer arithmetic which for historical reasons has to work the same
How can I find the high water mark (the historical maximum number of concurrent
I have inherited a Java application (servlets) that runs under Tomcat. For historical reasons,
I am using .NET 2.0 and SQL Server 2005. For historical reasons, the app
The company I work for has historically had very little process as far as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.