Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Using Umbraco 7.2 - created the following class in app_code, but the log entries never appear, and attach to process reveals no activity. Any help would be much appreciated :)
public class RegisterEvents : ApplicationEventHandler { protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { LogHelper.Debug(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "#debug1: ApplicationStarted"); ContentService.Saved += ContentSaved; } private void ContentSaved(IContentService sender, Umbraco.Core.Events.SaveEventArgs<Umbraco.Core.Models.IContent> e) { LogHelper.Debug(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "#debug1: ContentSaved"); }
I've also tried this, but still no luck:
public class RegisterEvents : IApplicationEventHandler
{
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
LogHelper.Debug(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType,
"#debug1: OnApplicationInitialized");
}
To be clear I'm looking in the umbracoLog table for results
Finally got this working. Looking in the wrong place for the log was one issue :p
For the record: this code works
public class RegisterEvents : ApplicationEventHandler { protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { //#debug - this logs to /App_Data/Logs/UmbracoTraceLog.txt //LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, // "#debug1: ApplicationStarted", new Exception("#ex1")); ContentService.Saved += ContentSaved; } private void ContentSaved(IContentService sender, Umbraco.Core.Events.SaveEventArgs<Umbraco.Core.Models.IContent> e) { //#debug //LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, // "#debug11: ContentSaved", new Exception("#ex11")); //calculate and save vat int contentId = e.SavedEntities.First().Id; //etc } }
Thanks @Mark, I've seen many ways of doing this and this one is the first one that's worked for me, so thanks for sharing :)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
ApplicationStarted not firing
Using Umbraco 7.2 - created the following class in app_code, but the log entries never appear, and attach to process reveals no activity. Any help would be much appreciated :)
I've also tried this, but still no luck:
public class RegisterEvents : IApplicationEventHandler
{
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
LogHelper.Debug(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType,
"#debug1: OnApplicationInitialized");
}
To be clear I'm looking in the umbracoLog table for results
Finally got this working. Looking in the wrong place for the log was one issue :p
For the record: this code works
Thanks @Mark, I've seen many ways of doing this and this one is the first one that's worked for me, so thanks for sharing :)
is working on a reply...