Click here to Skip to main content
15,885,067 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.5K   1.1K   32  
Introducing a small appender that logs to a web service within the LOG4NET logging framework
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="log4net" type="System.Configuration.IgnoreSectionHandler"/>
    </configSections>

    <log4net>
        <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
            <param name="File" value="test-client.log"/>
            <param name="AppendToFile" value="true"/>
            <param name="MaxSizeRollBackups" value="9"/>
            <param name="MaximumFileSize" value="40MB"/>
            <param name="RollingStyle" value="Size"/>
            <param name="StaticLogFileName" value="true"/>
            <layout type="log4net.Layout.PatternLayout">
                <param name="Header" value="[Header]\r\n"/>
                <param name="Footer" value="[Footer]\r\n"/>
                <param name="ConversionPattern" value="%d [%t] %-5p - %m%n"/>
            </layout>
        </appender>

		<appender name="WebServiceAppender" type="Zeta.WebServiceAppender">
			<!-- LOG4NET parameters. -->
			<filter type="log4net.Filter.LevelRangeFilter">
				<param name="LevelMin" value="DEBUG"/>
				<param name="LevelMax" value="FATAL"/>
			</filter>

			<!-- General parameters. -->
			<param name="ApiKey" value="{0E12B21A-95B9-11DB-96C0-005056C00008}" />

			<!-- WebService parameters. -->
			<param name="Url" value="http://localhost:2259/Web/LoggingService.asmx" />
			<param name="TimeoutSeconds" value="60" />

			<!-- Proxy parameters. -->
			<param name="UseProxy" value="false" />
			<param name="ProxyUrl" value="http://myproxy:3128" />
			<param name="ProxyBypassOnLocal" value="true" />
			<param name="ProxyUseDefaultCredentials" value="true" />
			<param name="ProxyCredentialsDomain" value="OFFICE" />
			<param name="ProxyCredentialsUserName" value="MyUser" />
			<param name="ProxyCredentialsPassword" value="MyPassword" />
		</appender>

        <root>
            <level value="ALL"/>
            <appender-ref ref="RollingLogFileAppender"/>
            <appender-ref ref="WebServiceAppender"/>
        </root>
    </log4net>
</configuration>

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