[jira] [Commented] (LOG4NET-407) AsyncAppender - better Implementation

2015-04-01 Thread Stefan Bodewig (JIRA)

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

Stefan Bodewig commented on LOG4NET-407:


svn revision 1670747 contains a hybrid of Michael's code, as well as code found 
in LOG4NET-344 and the existing AsyncAppender of the example.  It should keep 
event order for all versions and not lose LoggingEvents when used on .NET >= 
4.0.

Documentation is still needed, that's why I'm not closing the ticket 
immediately.

> AsyncAppender - better Implementation
> -
>
> Key: LOG4NET-407
> URL: https://issues.apache.org/jira/browse/LOG4NET-407
> Project: Log4net
>  Issue Type: Improvement
>  Components: Appenders
> Environment: .Net 4.0 and newer
>Reporter: Michael Goldfinger
>Priority: Minor
> Fix For: 1.3.0
>
>
> I checked out the AsyncAppender 
> (http://svn.apache.org/viewvc/logging/log4net/trunk/examples/net/2.0/Appenders/SampleAppendersApp/cs/src/Appender/AsyncAppender.cs?view=markup)
>  and found some drawbacks.
> * logevents are not logged if the appender close
> * order of logevents got lost
> I created an new implementation that waits for all logevents to be computed 
> before close and maintains the order of the events. If the application 
> process got killed the logevents are lost too but in any other case the loss 
> of logevents could be prevented. The drawback of my implementation is that 
> the TLP is requred so .NET 2.0 is not supported.
> I could not find the place to contribute so I created this ticket. I hope 
> it's useful.



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


[jira] [Commented] (LOG4NET-407) AsyncAppender - better Implementation

2014-02-12 Thread Michael Goldfinger (JIRA)

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

Michael Goldfinger commented on LOG4NET-407:


I used an  existing appender as reference (I think it was the 
BufferedAppender). Recursive Guard prevents an Loop if the async appender is 
placed inside an async appender in the config file. I did not test if this is 
really happening but the implementation I used as reference seems logical to me.

The thing is I was not sure if ErrorHandler.Error can handle simultaneous calls 
and did not check it. If there is no problem there should be no harm to move  
the try catch outside of the lock Statement


> AsyncAppender - better Implementation
> -
>
> Key: LOG4NET-407
> URL: https://issues.apache.org/jira/browse/LOG4NET-407
> Project: Log4net
>  Issue Type: Improvement
>  Components: Appenders
> Environment: .Net 4.0 and newer
>Reporter: Michael Goldfinger
>Priority: Minor
> Fix For: 1.3.0
>
>
> I checked out the AsyncAppender 
> (http://svn.apache.org/viewvc/logging/log4net/trunk/examples/net/2.0/Appenders/SampleAppendersApp/cs/src/Appender/AsyncAppender.cs?view=markup)
>  and found some drawbacks.
> * logevents are not logged if the appender close
> * order of logevents got lost
> I created an new implementation that waits for all logevents to be computed 
> before close and maintains the order of the events. If the application 
> process got killed the logevents are lost too but in any other case the loss 
> of logevents could be prevented. The drawback of my implementation is that 
> the TLP is requred so .NET 2.0 is not supported.
> I could not find the place to contribute so I created this ticket. I hope 
> it's useful.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)


[jira] [Commented] (LOG4NET-407) AsyncAppender - better Implementation

2014-02-02 Thread Jakub Linhart (JIRA)

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

Jakub Linhart commented on LOG4NET-407:
---

Many thanks for your AsyncAppender, it will be very useful. Beware using try, 
catch, finally inside the lock - it is very costly and most likely will cause 
drastic performance drop in massivelly parallel applications like ASP.NET due 
to high contention rate. Please, why do you use _recursiveGuard?

> AsyncAppender - better Implementation
> -
>
> Key: LOG4NET-407
> URL: https://issues.apache.org/jira/browse/LOG4NET-407
> Project: Log4net
>  Issue Type: Improvement
>  Components: Appenders
> Environment: .Net 4.0 and newer
>Reporter: Michael Goldfinger
>Priority: Minor
> Fix For: 1.3.0
>
>
> I checked out the AsyncAppender 
> (http://svn.apache.org/viewvc/logging/log4net/trunk/examples/net/2.0/Appenders/SampleAppendersApp/cs/src/Appender/AsyncAppender.cs?view=markup)
>  and found some drawbacks.
> * logevents are not logged if the appender close
> * order of logevents got lost
> I created an new implementation that waits for all logevents to be computed 
> before close and maintains the order of the events. If the application 
> process got killed the logevents are lost too but in any other case the loss 
> of logevents could be prevented. The drawback of my implementation is that 
> the TLP is requred so .NET 2.0 is not supported.
> I could not find the place to contribute so I created this ticket. I hope 
> it's useful.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)


[jira] [Commented] (LOG4NET-407) AsyncAppender - better Implementation

2013-11-25 Thread Michael Goldfinger (JIRA)

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

Michael Goldfinger commented on LOG4NET-407:


I added some performance tweaks. (Fix Property now only fixes values that 
depends on a thread.
And Fixed a little flaw in the public void DoAppend(LoggingEvent[] 
loggingEvents). The Fix Flag of the eventlogger could not be set via 
Parallel.Foreach because then the thread got lost ;).

> AsyncAppender - better Implementation
> -
>
> Key: LOG4NET-407
> URL: https://issues.apache.org/jira/browse/LOG4NET-407
> Project: Log4net
>  Issue Type: Improvement
>  Components: Appenders
> Environment: .Net 4.0 and newer
>Reporter: Michael Goldfinger
>Priority: Minor
> Fix For: 1.3.0
>
>
> I checked out the AsyncAppender 
> (http://svn.apache.org/viewvc/logging/log4net/trunk/examples/net/2.0/Appenders/SampleAppendersApp/cs/src/Appender/AsyncAppender.cs?view=markup)
>  and found some drawbacks.
> * logevents are not logged if the appender close
> * order of logevents got lost
> I created an new implementation that waits for all logevents to be computed 
> before close and maintains the order of the events. If the application 
> process got killed the logevents are lost too but in any other case the loss 
> of logevents could be prevented. The drawback of my implementation is that 
> the TLP is requred so .NET 2.0 is not supported.
> I could not find the place to contribute so I created this ticket. I hope 
> it's useful.



--
This message was sent by Atlassian JIRA
(v6.1#6144)


[jira] [Commented] (LOG4NET-407) AsyncAppender - better Implementation

2013-11-22 Thread Dominik Psenner (JIRA)

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

Dominik Psenner commented on LOG4NET-407:
-

Thanks for sharing your implementation. This might find it's way into the 1.3 
release of log4net.

> AsyncAppender - better Implementation
> -
>
> Key: LOG4NET-407
> URL: https://issues.apache.org/jira/browse/LOG4NET-407
> Project: Log4net
>  Issue Type: Improvement
>  Components: Appenders
> Environment: .Net 4.0 and newer
>Reporter: Michael Goldfinger
>Priority: Minor
> Fix For: 1.3.0
>
>
> I checked out the AsyncAppender 
> (http://svn.apache.org/viewvc/logging/log4net/trunk/examples/net/2.0/Appenders/SampleAppendersApp/cs/src/Appender/AsyncAppender.cs?view=markup)
>  and found some drawbacks.
> * logevents are not logged if the appender close
> * order of logevents got lost
> I created an new implementation that waits for all logevents to be computed 
> before close and maintains the order of the events. If the application 
> process got killed the logevents are lost too but in any other case the loss 
> of logevents could be prevented. The drawback of my implementation is that 
> the TLP is requred so .NET 2.0 is not supported.
> I could not find the place to contribute so I created this ticket. I hope 
> it's useful.



--
This message was sent by Atlassian JIRA
(v6.1#6144)


[jira] [Commented] (LOG4NET-407) AsyncAppender - better Implementation

2013-11-22 Thread Michael Goldfinger (JIRA)

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

Michael Goldfinger commented on LOG4NET-407:


This is my implementation
{code:java}
namespace Goldfinger.Appender
{
using System;
using System.Threading.Tasks;

using log4net.Appender;
using log4net.Core;
using log4net.Util;

/// 
/// Appender that forwards LoggingEvents asynchronously
/// 
/// 
/// This appender forwards LoggingEvents to a list of attached 
appenders.
/// The events are forwarded asynchronously using the PTL.
/// This allows the calling thread to be released quickly. This
/// implementation does guarantee the ordering of events deliverted 
to
/// the attached appenders, however it does not guarantee that all 
events
/// got logged if the application exits and there are events in the 
queue.
/// To force all events to be logged the last command of an 
application
/// before exit should be an LogManager.Shutdown() call.
/// 
public sealed class AsyncAppender : IBulkAppender, IOptionHandler, 
IAppenderAttachable
{
#region Static Fields

/// 
/// The declaring type.
/// 
private static readonly Type DeclaringType = 
typeof(AsyncAppender);

#endregion

#region Fields

private AppenderAttachedImpl _appenderAttachedImpl;

private Task _asyncLogTask;

private bool _closed;

private IErrorHandler _errorHandler;

private FixFlags _fixFlags = FixFlags.All;

private string _name;

private bool _recursiveGuard;

#endregion

#region Constructors and Destructors

/// 
/// Initializes a new instance of the  class.
/// 
public AsyncAppender()
{
_errorHandler = new 
OnlyOnceErrorHandler(GetType().Name);

// Initialise the task for the async operation.
// There is no need to do anything now, just make sure 
the Task got scheduled.
_asyncLogTask = new Task(() => { });
_asyncLogTask.Start();
}

/// 
/// Finalizes an instance of the  
class. 
/// 
~AsyncAppender()
{
// An appender might be closed then garbage collected. 
// There is no point in closing twice.
if (!_closed)
{
LogLog.Debug(DeclaringType, "Finalizing 
appender named [" + _name + "].");
Close();
}
}

#endregion

#region Public Properties

/// 
/// Gets the known appenders.
/// 
public AppenderCollection Appenders
{
get
{
lock (this)
{
return _appenderAttachedImpl == null ? 
AppenderCollection.EmptyCollection : _appenderAttachedImpl.Appenders;
}
}
}

/// 
/// Gets or sets the  for this 
appender.
/// 
/// The  of the 
appender
/// 
/// 
/// The  provides a 
default
/// implementation for the  
property.
/// 
/// 
public IErrorHandler ErrorHandler
{
get
{
return _errorHandler;
}

set
{
lock (this)
{
if (value == null)
{
// We do not throw exception 
here since the cause is probably a
// bad config file.
LogLog.Warn(DeclaringType, "You 
have tried to set a null error-handler.");
}
else
{