Hi, We also want to be careful not to change this central piece of code unless absolutely needed, i.e. if people start reporting bugs in this area. Log4j is in heavy use and this code has not significantly changed in years, so I'm inclined to think it's fairly solid ;)
Yoav Shapira Millennium Research Informatics >-----Original Message----- >From: Ceki G�lc� [mailto:[EMAIL PROTECTED] >Sent: Friday, September 17, 2004 2:51 PM >To: Log4J Developers List; Log4J Developers List >Subject: Re: Improving Log4J concurrency, avoiding deadlock > > >Do you realize that the main reason for synchronization in doAppend method >is avoiding simultaneous writes to the same output device? Any write >operation which is not synchronized (or otherwise protected against >simultaneous access) is a big no no... > >At 08:35 PM 9/17/2004, Elias Ross wrote: >>On Fri, 2004-09-17 at 10:40, Ceki Gülcü wrote: >> > Elias, >> > >> > How are your changes compatible with log4j 1.3 where layouts write >> directly >> > to the output stream without intermediary String objects? >> >>It would seem the same issue would occur if an appender is locked when a >>layout is writing directly to the output stream. >> >>Fundamentally, the changes would be the same. >> >>* Remove synchronization from AppenderSkeleton during doAppend >>(Possibly create a related class as the locking strategy is now >>different.) >>* subAppend would be changed as follows: >> >>src/java/org/apache/log4j/WriterAppender.java >> >> protected void subAppend(LoggingEvent event) { >> Layout l = this.layout; >> if (l == null) { >> errorHandler.error( >> "No layout set for the appender named [" + name + "]."); >> return; >> } >> Writer w = this.qw; >> if (w == null) >> return; >> try { >> l.formatAndWriteEvent(w, event); >> if (this.immediateFlush) { >> this.qw.flush(); >> } >> } catch (IOException e) { >> errorHandler.error("....") >> } >> >> } >> >>The only catch is if the threshold is being lowered when an event is >>going off. What will then happen is the event will be logged anyway. >> >>If the write is closed during the event, then potentially only half the >>stack trace will be logged if the writer is not locked. >> >>If this is a concern, you might want to create some sort of semaphore so >>that when an event is being logged, the appender state can't be >>affected. However, as many concurrent events can be logged at the same >>time. >> >> >> >>--------------------------------------------------------------------- >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] > >-- >Ceki G�lc� > > For log4j documentation consider "The complete log4j manual" > ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp > > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
