[ 
https://issues.apache.org/jira/browse/LOG4NET-447?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14242517#comment-14242517
 ] 

Gregory Babski commented on LOG4NET-447:
----------------------------------------

I did in fact implement a custom appender that extends MemoryAppender - based 
off of a much older version of log4net. I came to depend on the memory appender 
when our code is run in a manual test framework - redirecting log events to UI 
(rather than to file or syslog when the code runs ion production.) My 
implementation was initially aimed at fixing the ArrayOutOfBounds Exception, as 
I discovered is now fixed as described in 
https://issues.apache.org/jira/browse/LOG4NET-167.

I was updating our log4net dependencies and saw that fix and realised I could 
offer my changes for consideration.

Regarding the use obsolete tag - I defer to your experience, since I have never 
had to maintain widely used library.

Thanks for the feedback!

> MemoryAppender class is not thread safe
> ---------------------------------------
>
>                 Key: LOG4NET-447
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-447
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.13
>         Environment: .NET Framework 4.0 (Full Profile)
>            Reporter: Gregory Babski
>            Priority: Minor
>         Attachments: MemoryAppenderTest.cs, MemoryAppender_ThreadSafety.diff
>
>
> The memory appender cannot be used safely in an application that uses more 
> than one thread to interact with logging.
> When using this code to retrieve and then clear events logged in the memory 
> appender:
> var events = memoryAppender.GetEvents();
> memoryAppender.Clear();
> The executing thread may be preempted between these two calls and additional 
> logging events logged. These events are then cleared when the thread resumes 
> execution - and are never seen/processed.
> I expect to be be able to retrieve and clear the list of current events in 
> one call that guarantees that no events are ever lost.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to