KNOWLEDGE BASE

How do I use the Umbraco LogHelper method to trap errors and exceptions?


See below how to use the Umbraco LogHelper to log error messages to the UmbracoTraceLog.txt file.

Umbraco uses Log4Net for all it's logging, additional options can be set in the Log4net.config file.

@using Umbraco.Core.Logging
@{
    try
    {
        // your code here
    }
    catch (Exception ex)
    {
        LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Your headline message", ex);
    }
}


You can also use:

 LogHelper.Info(this.GetType(), "Message");                                    

Need an Umbraco Master?

Here at Simon Antony, we have an in house certified Umbraco Grand Master available for hire. Got a problem with your site, need architecture advice, give us a call to speak to Simon directly and see how we can help

Contact Simon Today!