Click here to Skip to main content
13,045,019 members (44,944 online)
Click here to Skip to main content
Add your own
alternative version


5 bookmarked
Posted 26 May 2013

SelfHosting Log4net SignalR Server

, 26 May 2013
Rate this:
Please Sign up or sign in to vote.
A log4Net appender with a selfHosting SignalR server.


I wrote an Log4net SignalR Server Appender, this Appender starts an SignalR Host on a defined Uri and starts logging when a client connects. The client defines the logging level. if the logging level is below root Root logging level (e.g., Debug and root Level is Error) i change the root logging level, and switch it back when the client (or clients) disconnect. You can connect as many Clients as you want.

I use SignalR because want to see the logs from wherever I want. And I want to connect with so many clients i want.


Did you know these Situations in which you have an Application that work good for months ?. Due logging performance issues you set the logging level to Error or Fatal. When you are about to forget this Application someone say "WTF!?! your application does not work anymore!!". So looking at the log Files something goes terrible wrong. But the Information you need is at Debug logging level and you do not have the rights to change anything.. (including the log4net configuration Files) and the Admin is on Holiday.

That is why I wrote Log4SignalR.

By the way sorry for my bad English.

Using the code 

All you need is to use the Appender is an .NET 4.5 application that is logging to log4net. (I put a Test Client and Server in the solution.)

Copy assemblies or include my project and change your log4net config like this:

    <appender name="SignalRAppender" type="Log4SignalR.SignalRAppender, Log4SignalR">
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline" />
        <Url value="http://localhost:8080/"/>        
        <level value="Warn" />
        <appender-ref ref="SignalRAppender" />

Do not apply a Level Filter or threshold to the appender I clear it both. The client level is the Filter.

If you use this; or have Problems with it, feel free to leave an comment.


Version  25.05.2013

Known limitations: Changing rootLogging Level manually at runtime, will be overwritten when a client connects / disconnects. Because I remember the root logging level at startup.

Only the shipped log4Net logging Levels supported. 


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


About the Author

Software Developer
Germany Germany
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionMy vote of 5 Pin
Win32nipuh8-Jan-15 5:06
memberWin32nipuh8-Jan-15 5:06 
AnswerRe: My vote of 5 Pin
Jan_Zimmermann9-Jan-15 3:07
memberJan_Zimmermann9-Jan-15 3:07 
GeneralRe: My vote of 5 Pin
Win32nipuh9-Jan-15 4:13
memberWin32nipuh9-Jan-15 4:13 
GeneralRe: My vote of 5 Pin
Jan_Zimmermann11-Jan-15 20:05
memberJan_Zimmermann11-Jan-15 20:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 26 May 2013
Article Copyright 2013 by Jan_Zimmermann
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid