New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

The Community Blog is a personal opinion of community members and by no means the official standpoint of DNN Corp or DNN Platform. This is a place to express personal thoughts about DNNPlatform, the community and its ecosystem. Do you have useful information that you would like to share with the DNN Community in a featured article or blog? If so, please contact .

The use of the Community Blog is covered by our Community Blog Guidelines - please read before commenting or posting.

Using log4net with DotNetNuke


log4net_dnnlog4net is a framework for documenting or processing errors and messages in your application. Allowing you to send errors and alerts to files, email, udp/tcp broadcasts and more. More details can be found on log4net’s website. log4net was added to DotNetNuke framework in version 6.0 which included updates to the source for sending general alerts to such as when a file is requested as well as parlaying the Exceptions.LogException() errors from the event viewer to log4net.

Getting Started – Monitoring

By default log4net is not enabled and the configuration is completely up to you but there are a few basics that you should utilize. To get started follow the following steps

  • Create a configuration file in your application root (same folder as your web.config) called DotNetNuke.log4net.config
  • Save the following configuration:
  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender"> 
    <file value="Portals/_default/Logs/" /> 
    <datePattern value="yyyy.MM.dd'.log.resources'" /> 
    <rollingStyle value="Date" /> 
    <staticLogFileName value="false" /> 
    <appendToFile value="true" /> 
    <param name="Threshold" value="ERROR" /> 
    <maximumFileSize value="10MB" /> 
    <maxSizeRollBackups value="5" /> 
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/> 
    <layout type="log4net.Layout.PatternLayout"> 
      <conversionPattern value="%date [%property{log4net:HostName}][Thread:%thread][%level] %logger - %message%newline" /> 
      <locationInfo value="true" /> 
    <level value="ALL" /> 
    <appender-ref ref="RollingFile" /> 

This configuration will give you daily date stamped log files in your /Portals/_default/Logs directory containing much of the same data available in your DNN Event Viewer.

A nice feature of the DotNetNuke.log4net.config implementation is the that you do not need to reset the application or cache for any changes to take effect. Nor does it automatically restart your application. You can enable and disable appenders on the fly.

Live monitoring of your application can be extremely valuable in development as well as in production to identify performance issues or attacks on your websites. With a few tweaks to the above configuration we can add another appender that will give us UDP broadcasts of errors.

  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender"> 
  <appender name="UDPBroadcast" type="log4net.Appender.UdpAppender"> 
    <param name="RemoteAddress" value="localhost" /> 
    <param name="RemotePort" value="877" /> 
    <param name="Threshold" value="ALL" /> 
    <layout type="log4net.Layout.XmlLayout"> 
      <locationInfo value="true" /> 
    <level value="ALL" /> 
    <appender-ref ref="RollingFile" /> 
    <appender-ref ref="UDPBroadcast" /> 

Now with a program like log4view we can consume these broadcasts and watch for any errors or alerts to see where in a stack our application may be and if any errors have arisen without reopening files or refreshing the DNN event viewer.



If you host multiple websites and you want to monitors errors for all of them in a central place then UDP broadcasting is a great way to aggregate them all.

Adding log4net to your modules

The core DNN framework is utilizing log4net but your custom built applications will get the benefits from Exception.LogException() function posting to log4net automatically but you can implement more granular alerts by referencing log4net in your application.image

  • Add a Reference to DotNetNuke.Log4Net.dll located in the bin directory of DotNetNuke
  • Now simply send the type of message alert you would like
    • DnnLog.Info(“Starting a really complex process! Wish me luck!”)
    • DnnLog.MethodEntry() or DnnLog.MethodExit() to send details about the function you’ve just entered or exited.
    • See the full list of public functions on right.


Declan Ward

I think the reference above is incorrect. It should be DotNetNuke.Instrumentation for DNN 7 at least. I don't know for other versions.
Declan Ward Wednesday, July 17, 2013 11:51 AM (link)
Winston Haybittle
Thanks, Live monitoring of IIS is definitely useful, I'm going to check this out.
Thanks again...
Winston Haybittle Monday, October 21, 2013 5:19 PM (link)

Comment Form

Only registered users may post comments.


Aderson Oliveira (22)
Alec Whittington (11)
Alessandra Davies (3)
Alex Shirley (10)
Andrew Hoefling (3)
Andrew Nurse (30)
Andy Tryba (1)
Anthony Glenwright (5)
Antonio Chagoury (28)
Ash Prasad (37)
Ben Schmidt (1)
Benjamin Hermann (25)
Benoit Sarton (9)
Beth Firebaugh (12)
Bill Walker (36)
Bob Kruger (5)
Bogdan Litescu (1)
Brian Dukes (2)
Brice Snow (1)
Bruce Chapman (20)
Bryan Andrews (1)
cathal connolly (55)
Charles Nurse (163)
Chris Hammond (213)
Chris Paterra (55)
Clint Patterson (108)
Cuong Dang (21)
Daniel Bartholomew (2)
Daniel Mettler (181)
Daniel Valadas (48)
Dave Buckner (2)
David Poindexter (12)
David Rodriguez (3)
Dennis Shiao (1)
Doug Howell (11)
Erik van Ballegoij (30)
Ernst Peter Tamminga (80)
Francisco Perez Andres (17)
Geoff Barlow (12)
George Alatrash (12)
Gifford Watkins (3)
Gilles Le Pigocher (3)
Ian Robinson (7)
Israel Martinez (17)
Jan Blomquist (2)
Jan Jonas (3)
Jaspreet Bhatia (1)
Jenni Merrifield (6)
Joe Brinkman (274)
John Mitchell (1)
Jon Henning (14)
Jonathan Sheely (4)
Jordan Coopersmith (1)
Joseph Craig (2)
Kan Ma (1)
Keivan Beigi (3)
Kelly Ford (4)
Ken Grierson (10)
Kevin Schreiner (6)
Leigh Pointer (31)
Lorraine Young (60)
Malik Khan (1)
Matt Rutledge (2)
Matthias Schlomann (16)
Mauricio Márquez (5)
Michael Doxsey (7)
Michael Tobisch (3)
Michael Washington (202)
Miguel Gatmaytan (3)
Mike Horton (19)
Mitchel Sellers (40)
Nathan Rover (3)
Navin V Nagiah (14)
Néstor Sánchez (31)
Nik Kalyani (14)
Oliver Hine (1)
Patricio F. Salinas (1)
Patrick Ryan (1)
Peter Donker (54)
Philip Beadle (135)
Philipp Becker (4)
Richard Dumas (22)
Robert J Collins (5)
Roger Selwyn (8)
Ruben Lopez (1)
Ryan Martinez (1)
Sacha Trauwaen (1)
Salar Golestanian (4)
Sanjay Mehrotra (9)
Scott McCulloch (1)
Scott Schlesier (11)
Scott Wilkinson (3)
Scott Willhite (97)
Sebastian Leupold (80)
Shaun Walker (237)
Shawn Mehaffie (17)
Stefan Cullmann (12)
Stefan Kamphuis (12)
Steve Fabian (31)
Steven Fisher (1)
Tony Henrich (3)
Torsten Weggen (3)
Tycho de Waard (4)
Vicenç Masanas (27)
Vincent Nguyen (3)
Vitaly Kozadayev (6)
Will Morgenweck (40)
Will Strohl (180)
William Severance (5)
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out