Learn More





DNN Community Blog

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.


2sic Daniel Mettler (124)
Aderson Oliveira (15)
Alec Whittington (11)
Alex Shirley (10)
Andrew Nurse (30)
Anthony Glenwright (5)
Antonio Chagoury (28)
Ash Prasad (21)
Ben Schmidt (1)
Benjamin Hermann (25)
Benoit Sarton (9)
Beth Firebaugh (12)
Bill Walker (36)
Bob Kruger (5)
Brian Dukes (2)
Brice Snow (1)
Bruce Chapman (20)
Bryan Andrews (1)
cathal connolly (55)
Charles Nurse (163)
Chris Hammond (203)
Chris Paterra (55)
Clinton Patterson (28)
Cuong Dang (21)
Daniel Bartholomew (2)
Dave Buckner (2)
David Poindexter (3)
David Rodriguez (2)
Doug Howell (11)
Erik van Ballegoij (30)
Ernst Peter Tamminga (74)
Geoff Barlow (6)
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 (269)
John Mitchell (1)
Jon Henning (14)
Jonathan Sheely (4)
Jordan Coopersmith (1)
Joseph Craig (2)
Kan Ma (1)
Keivan Beigi (3)
Ken Grierson (10)
Kevin Schreiner (6)
Leigh Pointer (31)
Lorraine Young (60)
Malik Khan (1)
Matthias Schlomann (15)
Mauricio Márquez (5)
Michael Doxsey (7)
Michael Tobisch (3)
Michael Washington (202)
Mike Horton (19)
Mitchel Sellers (28)
Nathan Rover (3)
Navin V Nagiah (14)
Néstor Sánchez (31)
Nik Kalyani (14)
Peter Donker (52)
Philip Beadle (135)
Philipp Becker (4)
Richard Dumas (22)
Robert J Collins (5)
Roger Selwyn (8)
Ruben Lopez (1)
Ryan Martinez (1)
Salar Golestanian (4)
Sanjay Mehrotra (9)
Scott McCulloch (1)
Scott S (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)
Timo Breumelhof (24)
Tony Henrich (3)
Torsten Weggen (2)
Vicenç Masanas (27)
Vincent Nguyen (3)
Vitaly Kozadayev (6)
Will Morgenweck (37)
Will Strohl (163)
William Severance (5)
Try Evoq
For Free
Start Free Trial
a Demo
See Evoq Live
Need More Information?