I am using Umbraco 7.5.12.
I have a class which is supposed to log errors but the entries do not appear in umbraco log file.
Though message to admin sends well:
public class ErrorReporting
{
private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static void LogError(Exception ex, string messageIntro, string id = null)
{
Logger.Error(messageIntro, ex);
Error adminErrorMessage = new Error();
adminErrorMessage.Send(ex, id);
}
}
The url of the log file seems to be set correctly:
<file type="log4net.Util.PatternString" value="App_Data\Logs\UmbracoTraceLog.%property{log4net:HostName}.txt" />
and umbraco logs its errors correctly.
ErrorReporting
class is in a separate project which is referenced in the starting project anyway and above log file setting is obviously in the starting project but it shouldn't be the issue?
I checked log4net enabled settings:
bool IsErrorEnabled = Logger.IsErrorEnabled;
bool IsFatalEnabled = Logger.IsFatalEnabled;
bool IsDebugEnabled = Logger.IsDebugEnabled;
bool IsInfoEnabled = Logger.IsInfoEnabled;
bool IsWarnEnabled = Logger.IsWarnEnabled;
and IsDebugEnabled
is false. Can this be an issue?
I usally use the Loghelper
located in Umbraco.Core.Logging
using Umbraco.Core.Logging;
public class ErrorReporting
{
public static void LogError(Exception ex, string messageIntro, string id = null)
{
LogHelper.Error(typeof(ErrorReporting), messageIntro, ex);
Error adminErrorMessage = new Error();
adminErrorMessage.Send(ex, id);
}
}
Some additional information can be found here