Live logging with log4net and WCF part 2

In previous post I showed how to create a publish/subscribe logger with WCF and log4net, now I show you my first use of this particular appender.

When you work with nhibernate you can use show-sql configuration parameter to instruct nhibernate to show generated sql, but how can you see this output in a running windows application? You should know that NHibernate has various log4Net logger, and you can instruct the session to dump all sql code to a logger, here it is a possible configuration

<appender name="WCFAppender" type="LiveLogger4Log4Net.WCFAppender, LiveLogger4Log4Net"> <layout type="log4net.Layout.PatternLayout" > <conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline" /> </layout> </appender> <logger name="NHibernate.SQL" additivity="false"> <level value="DEBUG" /> <appender-ref ref="WCFAppender" /> </logger>

With this configuration I instruct NHibernate to log to WCFAppender all generated SQL. Now I can attach a log viewer to a running application and look in real time to the sql instruction that nhibernate generates. You can attach more than one application, whenever you want.


Welcome to log4net live logging monitor 😀



DotNetKicks Image

Published by

Ricci Gian Maria

.Net programmer, User group and community enthusiast, programmer - aspiring architect - and guitar player :). Visual Studio ALM MVP

2 thoughts on “Live logging with log4net and WCF part 2”

  1. Nice article! Can you please make source code in a zip file rather than in the SVN. I have difficulties in get the source file through SVN. My requests are all rejected (Forbidden).

Comments are closed.