9

Does DotNetNuke provide any built in Error Logging framework? My client is using DotNetNuke and I don't see a global error logging framework. I see the class below with some try/catch's using them.

namespace DotNetNuke.Services.Exceptions
{
    [StandardModule]
    public sealed class Exceptions
    {
        public static ExceptionInfo GetExceptionInfo(Exception e);
        public static void LogException(Exception exc);
        public static void LogException(ModuleLoadException exc);
        public static void LogException(PageLoadException exc);
        public static void LogException(SchedulerException exc);
        public static void LogException(SecurityException exc);
        public static void LogSearchException(SearchException exc);
        public static void ProcessModuleLoadException(Control ctrl, Exception exc);
        public static void ProcessModuleLoadException(PortalModuleBase objPortalModuleBase, Exception exc);
        public static void ProcessModuleLoadException(Control ctrl, Exception exc, bool DisplayErrorMessage);
        public static void ProcessModuleLoadException(PortalModuleBase objPortalModuleBase, Exception exc, bool DisplayErrorMessage);
        public static void ProcessModuleLoadException(string FriendlyMessage, Control ctrl, Exception exc);
        public static void ProcessModuleLoadException(string FriendlyMessage, Control ctrl, Exception exc, bool DisplayErrorMessage);
        public static void ProcessModuleLoadException(string FriendlyMessage, PortalModuleBase objPortalModuleBase, Exception exc, bool DisplayErrorMessage);
        public static void ProcessPageLoadException(Exception exc);
        public static void ProcessPageLoadException(Exception exc, string URL);
        public static void ProcessSchedulerException(Exception exc);
    }
}
Alexander
  • 2,320
  • 2
  • 25
  • 33
Mike Flynn
  • 22,342
  • 54
  • 182
  • 341

4 Answers4

20

Log4Net is available, but most modules use the custom exceptions class within DNN which will store "events" in the EventLog table, you can access the reports for "events" including errors, from the Admin/Event Viewer page.

Typically within a module you would do something like the following.

try
{
    //STUFF HERE
}
catch (Exception exc) //Module failed to load
{
    Exceptions.ProcessModuleLoadException(this, exc);
}
Alexander
  • 2,320
  • 2
  • 25
  • 33
Chris Hammond
  • 8,873
  • 1
  • 26
  • 34
  • Hi Chris, I saw this in your template and am glad I came hear to understand what it is actually doing. In the OP question there are function definitions that include 'FriendlyMessage'. Is this field intended to allow the developer to log additional details or is this what gets displayed to the user when the error occurs. If it isn't a place for custom info about the exception, is there? – RacerNerd Oct 04 '13 at 01:58
  • @RacerNerd I haven't tried using friendlymessage before, but my guess is it would be what displays to the end user when there's a problem – Chris Hammond Oct 04 '13 at 02:29
7

DNN includes log4net, see this wiki article: http://dnnsoftware.com/Wiki/Page/log4net-In-DotNetNuke

bdukes
  • 152,002
  • 23
  • 148
  • 175
demo.b
  • 3,299
  • 2
  • 29
  • 29
4

It has been a long time since the original post about this and after doing some research for myself I believe I found a better and more recent resource than the accepted answer. The following includes a little more information about how to get Log4Net set up and integrated into your modules, http://www.dnnsoftware.com/community-blog/cid/141723/Using-log4net-with-DotNetNuke.

It appears that one advantage to using the Log4Net approach is the ability to configure the logging level so applications can be more easily investigated and debugged. This can be especially helpful when moving applications between environments. I used this while debugging an application on a server where I can't attach to the process and interupt the application to debug. I turn up the logging level and work with the info in the log. This can be painful a painful way to debug, but really helpful when you are stuck.

In DNN 7 the DnnLog class mentioned here is depreciated so alternatives should probably be explored.

It looks like the custom exceptions class is intended for exceptions that need to be logged in all cases. I found this slightly older article that is likely still relevant if there is the need to log custom information, http://www.ifinity.com.au/Blog/EntryId/114/Creating-Exception-Logging-with-DotNetNuke. Some classes will need to be updated but the overall technique looked good and goes more in line with Chris's suggestion above. With a little tweaking this example could be used to implement a configurable logging level.

RacerNerd
  • 1,579
  • 1
  • 13
  • 31
1

My understanding is that you have the following options:

Community
  • 1
  • 1
Valentin
  • 717
  • 10
  • 21