I was thinking the same line but problem solved only by closing the appender when work done Sent from BlackBerry® on Airtel
-----Original Message----- From: "Jacob Kjome" <h...@visi.com> Date: Tue, 15 Feb 2011 09:45:15 To: Log4J Users List<log4j-user@logging.apache.org> Reply-To: "Log4J Users List" <log4j-user@logging.apache.org> Subject: Re: FileAppender problem I suggest using a ServletContextLister and calling LogManager.shutdown() when your webapp is stopped. http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/LogManager.html#shutdown%28%29 http://stackoverflow.com/questions/839255/how-do-i-properly-log4j-closing-all-appenders-and-therefore-files Jake On Tue, 15 Feb 2011 10:06:57 +0530 Umesh Awasthi <umeshawas...@gmail.com> wrote: > Josef, > > Thanks for the help.i able to solve the problem and here is the casue of the > problem'. > since i was creating fileappender instance > appender = new FileAppender(layout, sb.toString(), false); > inside the constructor of my class and i was of impression that log4j is > responsible for closing the appender which in my case was not happening at > all. > so after looking in to the FileAppender source code i got the hint since in > the code they tried to close the appender but code was indicating that there > may be some cases where appender might still be open and my problem was in > this section,so after doing my work i simply closed the appender and it > solved the whole issue. > > still i am not sure how tomcat was keeping refrence of all the appender > created by the code since i was cleaning up my code and was making all > refrences null. > > any one have idea,please do share > > > > On Mon, Feb 14, 2011 at 11:23 PM, Stadelmann Josef < > josef.stadelm...@axa-winterthur.ch> wrote: > >> In case you have conflicts, it is a good Idea to consolidate all different >> log4j.properties into one big log4j.properties and have that used when >> TOMCAT starts. This just fior a test. If then all runs, then your problems >> may be that of a access conflict; i.e. trying to open a file or a channel >> which is already open. >> >> It helped for me in many case. >> Josef >> >> >> >> -----Ursprüngliche Nachricht----- >> Von: Umesh Awasthi [mailto:umeshawas...@gmail.com] >> Gesendet: Montag, 14. Februar 2011 15:35 >> An: log4j-user >> Betreff: Re: FileAppender problem >> >> Hi All, >> >> Can any one help me in this,it seems the my tomcat server keeping a >> refrence >> of all fileappender >> >> On Sat, Feb 12, 2011 at 11:22 AM, Umesh Awasthi <umeshawas...@gmail.com >> >wrote: >> >> > Hi All, >> > >> > 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. >> > >> > here is the code to create log file at run time >> > 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 starting >> > appending the log content not only to its pareent class as well other >> > classes.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 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. >> > >> > >> > -- >> > With Regards >> > Umesh Awasthi >> > http://www.travellingrants.com/ >> > >> > >> > >> >> >> >> -- >> With Regards >> Umesh Awasthi >> http://www.travellingrants.com/ >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org >> For additional commands, e-mail: log4j-user-h...@logging.apache.org >> >> > > > -- > With Regards > Umesh Awasthi > http://www.travellingrants.com/ --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org