Click here to Skip to main content
Click here to Skip to main content

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.

Introduction

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.

Background

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:

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

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.

History 

Version 1.0.0.0  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. 

License

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

Share

About the Author

Jan_Zimmermann
Software Developer
Germany Germany
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 26 May 2013
Article Copyright 2013 by Jan_Zimmermann
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid