Probably one for the core team. I am doing some custom logging in my class using the umbraco logging api in v6 which logs out using log4net my code looks like
LogHelper.Error<Exception>("Error writing to eloqua for email address " + record.EmailAddress, ex);
I have as well the default file appender setup and email appender with a filter. So my log4net smtp appender looks like
I do not get an email when an error occurs. I go get message in log file. However one thing I noticed is that in the logfile there is no type for where occur occurred. So when you have umbraco errors in the log you have
ERROR Umbraco.Core.PluginManager
ERROR umbraco.DataLayer.SqlHelper
For my error you see ERROR System.Exception so I guess when logging is happening in the bowels of umbraco the logger is given type where as when we log its not? Is this why my filter misses the exception? Do i need to log directly using log4net like umbraco in the bowels does? That is assuming umbraco does it directly with log4net and not with an abstraction around log4net?
Though as this was written in 2013, you should be aware that the Log.Error() approach has been superseded by the LogHelper.Error() implementation, the article is however incredibly helpful when setting up custom logs and specifying applicable namespaces for those logs to be written from.
Log4net logging
Guys,
Probably one for the core team. I am doing some custom logging in my class using the umbraco logging api in v6 which logs out using log4net my code looks like
LogHelper.Error<Exception>("Error writing to eloqua for email address " + record.EmailAddress, ex);
I have as well the default file appender setup and email appender with a filter. So my log4net smtp appender looks like
<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
<to value="xxx" />
<from value="xxx" />
<subject value="Info graphic error" />
<smtpHost value="localhost" />
<bufferSize value="512" />
<lossy value="true" />
<evaluator type="log4net.Core.LevelEvaluator">
<threshold value="ERROR"/>
</evaluator>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%newline%date [%thread] %-5level %logger [%property{NDC}] - %message%newline%newline%newline" />
</layout>
<filter type="log4net.Filter.LoggerMatchFilter">
<loggerToMatch value="MyProject.BusinessLogic.Helpers.RazorHelper" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
</appender>
I do not get an email when an error occurs. I go get message in log file. However one thing I noticed is that in the logfile there is no type for where occur occurred. So when you have umbraco errors in the log you have
ERROR Umbraco.Core.PluginManager
ERROR umbraco.DataLayer.SqlHelper
For my error you see ERROR System.Exception so I guess when logging is happening in the bowels of umbraco the logger is given type where as when we log its not? Is this why my filter misses the exception? Do i need to log directly using log4net like umbraco in the bowels does? That is assuming umbraco does it directly with log4net and not with an abstraction around log4net?
Regards
Ismail
So in answer to my own question. Im an idiot!! So if log the error as
LogHelper.Error(typeof(RazorHelper), "Error writing to eloqua for email address " + record.EmailAddress, webex);
It all works woohoo!
Regards
Ismail
Is there documentation somewhere on how to use the logger in Umbraco?
I'm afraid not John, you get the same level of documentation as with most other features - nothing beyond the source code.
When implementing my own custom logging I found the following blog post incredibly helpful: http://blog.darren-ferguson.com/2013/02/22/log4net-logging-from-your-custom-code-in-umbraco/
Though as this was written in 2013, you should be aware that the Log.Error() approach has been superseded by the LogHelper.Error() implementation, the article is however incredibly helpful when setting up custom logs and specifying applicable namespaces for those logs to be written from.
is working on a reply...