logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Georg Jansen" <Georg.Jan...@FaktNet.com>
Subject RE: Is there anything resembling a "WebServicesAppender"?
Date Mon, 16 Jan 2006 02:37:03 GMT



Since web services are (relatively) slow, I would consider breaking this
into two different processes. And do the web services call in a separate
thread or process (depending on how performance critical this is).


Hollywoods code could probably be modified to start a separate thread to
invoke the web service. You could also make the appender "buffered" and send
several log events on the same time.


Another approach would be to store the log events on a kind of a queue (for
example a file or a database table), and write a small program that consumes
this queue and invokes the web service.


I realize that it is several different approaches to solve this, so this was
just my $0.02.



Best regards


http://www.l4ndash.com <http://www.l4ndash.com/>  - Log4Net Dashboard / Log




-----Original Message-----
From: Hollywood [mailto:hollywood@thzero.com] 
Sent: 16. januar 2006 03:04
To: Log4NET User
Subject: Re: Is there anything resembling a "WebServicesAppender"?


No, but its pretty easy to write one.  We had exactly the same situation 

where we need to post errors to the server and use a webservice to do it. 

Here's a pretty simple one, but it was written for a previous version of 

Log4Net but should give general idea (btw, InitializeService is a method 

that was created to set security, urls, etc. on the webservice).


/// <summary>

/// Summary description for ServiceAppender.

/// </summary>

public class ServiceAppender : AppenderSkeleton


 public ServiceAppender()


  //Do any intialization here.



 #region Implementation of IOptionHandler


 public override void ActivateOptions()


  base.ActivateOptions ();


  //Provide any checks based on Service config properties, if Service

  //config properties are valid initialize ServiceAppender.








 #region Override implementation of AppenderSkeleton


 protected override void Append(LoggingEvent loggingEvent)


  //Set any necessary loggingEvent properties.

  //(e.g. loggingEvent.Properties[LoggingEvent.HostNameProperty] = 


  /* TODO */




   //Call the WebService Logger.

   // TODO: Decide how to proceed. This normally is controlled from the 

App.Config file,

   //   but if it gets changed to something less than a level of Error by 


   //   not knowing the ramifications, it could cause an enormous amount of 



   // TODO: I want to checkin a workable copy, I don't have rights to update

manaslu with updated WebService.  After updating manaslu then uncomment and 


   //if (loggingEvent.Level.Name.ToUpper() == "ERROR" || 

loggingEvent.Level.Name.ToUpper() == "FATAL")


loggingEvent.RenderedMessage, Environment.UserName, 





  catch(Exception exc)


   ErrorHandler.Error("Unable to send loggingEvent to Logging Service", exc,






 protected override bool RequiresLayout


  get { return false; }




 public override void OnClose()


  base.OnClose ();


  //Release any resource that were needed.






 #region Private Methods


 private void InitializeServiceConnection()




   //Code any Service initialization needed for ServiceAppender to work.

   //This is called from ActiveOptions.

   //Instantiate the WebService.

   if (_serviceLogging == null)

    _serviceLogging = 



  catch(Exception exc)


   // TODO: Add Service name to error message.

   ErrorHandler.Error("Could not initialize the service", exc, 



   // TODO: Reset the Service object to a known state if needed.






 #region Fields


 private Logging.LoggingService _serviceLogging = null;




----- Original Message ----- 

From: "Billy Barnum" <bbarnum@spamcop.net>

To: <log4net-user@logging.apache.org>

Sent: Sunday, January 15, 2006 5:27 PM

Subject: Is there anything resembling a "WebServicesAppender"?



> I've gotten pretty familiar with the file, smtp, adonet, and eventlog

> appenders, and have even written my own simple extensions. Now I'm being

> asked to make log4net logging happen over the public internet from a .NET

> Winforms client app, and I'm on unfamiliar ground.


> The client is a .NET Winforms app that will do some work locally and hit 

> up

> servers over http via .NET web services for other work, but log entries 

> must

> be made to the central servers. My customer doesn't want to log locally 

> and

> then have users email local logs; they want to see errors and info entries

> as they happen, or pretty soon thereafter. Ultimately, log entries are to 

> be

> written to NTFS files a la FileAppender.


> I'm talking about something resembling a "Web Services Appender", 

> methinks.


> Is there some relatively easy way to achieve this with RemotingAppender 

> and

> an almost-empty server host in IIS that just passes everything through via

> a

> server-side log4net config file that names a FileAppender? Or is there

> another, better approach?


> I'm looking for general advice, samples, links to other resources - 

> anything

> at all. Grateful for whatever tidbits I can get that don't take up too 

> much

> of folks' time. Thanks in advance.


> -BillyB


View raw message