Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nagarjun 39 posts 71 karma points
    Sep 30, 2020 @ 09:18
    Nagarjun
    0

    Umbraco 8.6.4 Content Service publish event not working for me. Any suggestions please.

    Hi,

    I followed the inline url and tried capturing published event.

    https://our.umbraco.com/documentation/getting-started/Code/Subscribing-To-Events/

    However debug point is not hitting the publish event. I checked log files and logs were also not captured. Could anyone please try and let me know how to handle content service publish events.

    I tried the following ways, but still no luck. 1. Visual studio IDE debugging. 2. Hosted site in IIS.

    Code :-

    using Umbraco.Core.Composing;
    using Umbraco.Core.Services.Implement;
    using Umbraco.Core.Logging;
    
    
    namespace Azure_Deployment_Production.Events
    {
        public class LogWhenContentPublished : IComponent
        {
    
            private readonly ILogger _logger;
            public LogWhenContentPublished(ILogger logger)
            {
                _logger = logger;
    
            }
    
    
            public void Initialize()
            {
    
                ContentService.Published += ContentService_Published;
            }
    
            private void ContentService_Published(Umbraco.Core.Services.IContentService sender, Umbraco.Core.Events.ContentPublishedEventArgs e)
            {
    
                _logger.Info<LogWhenContentPublished>("Something has been published...");
                foreach (var publishedItem in e.PublishedEntities)
                {
                    _logger.Info<LogWhenContentPublished>(publishedItem.Name + " was published");
                }
    
            }
            public void Terminate()
            {
                // unsubscribe on shutdown
                ContentService.Published -= ContentService_Published;
            }
        }
    
  • Casper 70 posts 308 karma points
    Sep 30, 2020 @ 09:20
    Casper
    0

    You need to register/compose your component:

        public class LogWhenContentPublishedComposer : ComponentComposer<LogWhenContentPublished> { }
    
Please Sign in or register to post replies

Write your reply to:

Draft