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 3968620
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:51:54+00:00 2026-05-20T03:51:54+00:00

I am working on a webapplication and i have a requirment to generate log

  • 0

I am working on a webapplication and i have a requirment to generate log files at run time for my impex process.here is the use case
i am validating an XML file and validation error is being handled by custom Error handler.This error hanlde will be passed to the underlying validator (Jaxb 2.x validator),so i have to create the log file when the instance of this error hanlder is being created.
we are using log4j as logging API

here is the code to create log file at run time

XMLErrorHandler<Object> errorHandler=new XMLErrorHandler<Object>(logFileLocation);
        logFileName=errorHandler.getLogFileName();
        validator.setErrorHandler(errorHandler);
            validator.validate(source);

i am creating the log file inside XMLErrorHandler constructor since this is the only point i have control here is the code for the log file creation

FileAppender appender;
            try {
                appender = new FileAppender(layout, sb.toString(), false);
                log.addAppender(appender);
                log.setAdditivity(false);
                log.setLevel(Level.WARN);
            } catch (IOException e) {
                e.printStackTrace();
            }

everything is working fine and file is being created correctly as well being written by the logger to the respective place.
but if i restart my server real problem starts and logger start appending the log content not only to its current log file but also for all file being created for this process while server is running. Here is the details
lets suppose i have 3 log (A,B,C) files already at the location with 3 lines in each log file and C was the latest file created in the process.
so when i restart my server(By resrarting i mean i stopped tomcat from the console) it some how appending data in to previos all log files in this fashin
C has still 3 lines
B has now 6 lines
A has now 9 lines

it seems that the appender i hace created is still open or have refrence, not sure what exactly going on.
any help in this regard will be helpfull.

  • 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-20T03:51:55+00:00Added an answer on May 20, 2026 at 3:51 am

    Problem solved..
    Issue was with the appender i was using.i was of impression that log4j handle closing of appender by itself but it was not doing this (i saw FileAppender code as it was trying to close appender).
    so i closed the appender myself and it solved the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a web application and I have run into the following
I have am working on a web application that makes use of helper classes.
I'm working on a web application that will have a custom UI for the
I'm currently working on web application using VB in ASP.NET. Right now I have
I'm working on a web application using JSP/Servlets, etc. And I have a lot
I have a web application that I'm working on for work and its not
I have created a Web Application in asp.net 2.0. which is working fine on
I am working on an auction web application. Now i have a table with
I am working on a webapplication and I do most of the XHTML stuff
I am working with listview in C# webapplication. My Problem is I want checked

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.