Click here to Skip to main content
15,896,154 members
Articles / Operating Systems / Windows

LOG4NET WebServiceAppender

Rate me:
Please Sign up or sign in to vote.
4.25/5 (9 votes)
27 Dec 2006CPOL3 min read 55.7K   1.1K   32  
Introducing a small appender that logs to a web service within the LOG4NET logging framework
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.42
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

// 
// This source code was auto-generated by Microsoft.VSDesigner, Version 2.0.50727.42.
// 
#pragma warning disable 1591

namespace Zeta.Logging {
    using System.Diagnostics;
    using System.Web.Services;
    using System.ComponentModel;
    using System.Web.Services.Protocols;
    using System;
    using System.Xml.Serialization;
    
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.42")]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="LoggingServiceSoap", Namespace="http://webservices.zeta-sw.com/Log4NetWebServiceAppender")]
    public partial class LoggingService : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        private System.Threading.SendOrPostCallback LogOperationCompleted;
        
        private bool useDefaultCredentialsSetExplicitly;
        
        /// <remarks/>
        public LoggingService() {
            this.Url = global::Zeta.Properties.Settings.Default.ZetaWebServiceAppender_Logging_LoggingService;
            if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
                this.UseDefaultCredentials = true;
                this.useDefaultCredentialsSetExplicitly = false;
            }
            else {
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        
        public new string Url {
            get {
                return base.Url;
            }
            set {
                if ((((this.IsLocalFileSystemWebService(base.Url) == true) 
                            && (this.useDefaultCredentialsSetExplicitly == false)) 
                            && (this.IsLocalFileSystemWebService(value) == false))) {
                    base.UseDefaultCredentials = false;
                }
                base.Url = value;
            }
        }
        
        public new bool UseDefaultCredentials {
            get {
                return base.UseDefaultCredentials;
            }
            set {
                base.UseDefaultCredentials = value;
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }
        
        /// <remarks/>
        public event LogCompletedEventHandler LogCompleted;
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://webservices.zeta-sw.com/Log4NetWebServiceAppender/Log", RequestNamespace="http://webservices.zeta-sw.com/Log4NetWebServiceAppender", ResponseNamespace="http://webservices.zeta-sw.com/Log4NetWebServiceAppender", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public void Log(WebServiceCommunicationInformation info) {
            this.Invoke("Log", new object[] {
                        info});
        }
        
        /// <remarks/>
        public void LogAsync(WebServiceCommunicationInformation info) {
            this.LogAsync(info, null);
        }
        
        /// <remarks/>
        public void LogAsync(WebServiceCommunicationInformation info, object userState) {
            if ((this.LogOperationCompleted == null)) {
                this.LogOperationCompleted = new System.Threading.SendOrPostCallback(this.OnLogOperationCompleted);
            }
            this.InvokeAsync("Log", new object[] {
                        info}, this.LogOperationCompleted, userState);
        }
        
        private void OnLogOperationCompleted(object arg) {
            if ((this.LogCompleted != null)) {
                System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
                this.LogCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
            }
        }
        
        /// <remarks/>
        public new void CancelAsync(object userState) {
            base.CancelAsync(userState);
        }
        
        private bool IsLocalFileSystemWebService(string url) {
            if (((url == null) 
                        || (url == string.Empty))) {
                return false;
            }
            System.Uri wsUri = new System.Uri(url);
            if (((wsUri.Port >= 1024) 
                        && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
                return true;
            }
            return false;
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.42")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://webservices.zeta-sw.com/Log4NetWebServiceAppender")]
    public partial class WebServiceCommunicationInformation {
        
        private string apiKeyField;
        
        private string contextInformationField;
        
        private string levelField;
        
        private string messageField;
        
        private string exceptionSerializedAsStringField;
        
        /// <remarks/>
        public string ApiKey {
            get {
                return this.apiKeyField;
            }
            set {
                this.apiKeyField = value;
            }
        }
        
        /// <remarks/>
        public string ContextInformation {
            get {
                return this.contextInformationField;
            }
            set {
                this.contextInformationField = value;
            }
        }
        
        /// <remarks/>
        public string Level {
            get {
                return this.levelField;
            }
            set {
                this.levelField = value;
            }
        }
        
        /// <remarks/>
        public string Message {
            get {
                return this.messageField;
            }
            set {
                this.messageField = value;
            }
        }
        
        /// <remarks/>
        public string ExceptionSerializedAsString {
            get {
                return this.exceptionSerializedAsStringField;
            }
            set {
                this.exceptionSerializedAsStringField = value;
            }
        }
    }
    
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.42")]
    public delegate void LogCompletedEventHandler(object sender, System.ComponentModel.AsyncCompletedEventArgs e);
}

#pragma warning restore 1591

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Zeta Software GmbH
Germany Germany
Uwe does programming since 1989 with experiences in Assembler, C++, MFC and lots of web- and database stuff and now uses ASP.NET and C# extensively, too. He has also teached programming to students at the local university.

➡️ Give me a tip 🙂

In his free time, he does climbing, running and mountain biking. In 2012 he became a father of a cute boy and in 2014 of an awesome girl.

Some cool, free software from us:

Windows 10 Ereignisanzeige  
German Developer Community  
Free Test Management Software - Intuitive, competitive, Test Plans.  
Homepage erstellen - Intuitive, very easy to use.  
Offline-Homepage-Baukasten

Comments and Discussions