Yes, we only use it on error and fatal messages, so usually its not that time consuming. Also its set to use an async call so it doesn't wait for a return message. That all being said, Georg is right about the relative slowness of the web services.

----- Original Message ----- From: "Georg Jansen" <[EMAIL PROTECTED]>
To: "'Log4NET User'" <[email protected]>
Sent: Sunday, January 15, 2006 8:37 PM
Subject: RE: Is there anything resembling a "WebServicesAppender"?




Billy,



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

Georg

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







-----Original Message-----
From: Hollywood [mailto:[EMAIL PROTECTED]
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.



 InitializeServiceConnection();

}





#endregion



#region Override implementation of AppenderSkeleton



protected override void Append(LoggingEvent loggingEvent)

{

 //Set any necessary loggingEvent properties.

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

SystemInfo.HostName;

 /* TODO */



 try

 {

  //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

someone

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

traffic.



// 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

checkin.

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

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

   _serviceLogging.RMSServiceLogger(loggingEvent.Level.Name,

loggingEvent.RenderedMessage, Environment.UserName,

Environment.UserDomainName,

((AppBaseLoader)AppLoader.Instance).PersonSystemUserGuid,

SystemInfo.HostName);

 }

 catch(Exception exc)

 {

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


ErrorCodes.WriteFailure);

 }

}





protected override bool RequiresLayout

{

 get { return false; }

}





public override void OnClose()

{

 base.OnClose ();



 //Release any resource that were needed.



}



#endregion



#region Private Methods



private void InitializeServiceConnection()

{

 try

 {

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

  //This is called from ActiveOptions.

  //Instantiate the WebService.

  if (_serviceLogging == null)

   _serviceLogging =

(Logging.LoggingService)InitializeService(typeof(Logging.LoggingService));

 }

 catch(Exception exc)

 {

  // TODO: Add Service name to error message.

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

ErrorCodes.GenericFailure);



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

 }

}



#endregion



#region Fields



private Logging.LoggingService _serviceLogging = null;



#endregion



----- Original Message -----
From: "Billy Barnum" <[EMAIL PROTECTED]>

To: <[email protected]>

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





Reply via email to