Try our conversational search powered by Generative AI!

HXH
HXH
May 11, 2010
  4428
(0 votes)

Adding an Additional Layer of Logging to EPiServer Actions

Part of my standard Workflow Implementation is an additional layer of logging that sits in a table outside of the standard EPiServer installation. I’ve found that keeping a record of a few basic EPiServer actions can really help to paint an accurate picture of which editors are doing what.

To log the actions as they are executed, I first created a custom property with the [PagePlugIn] Attribute. I then created a method called Initialize, which adds additional processing capabilities to events exposed through DataFactory.Instance.

The result is something like the following:

    [PagePlugIn]
    public class CustomPageActionControl
    {
        public static void Initialize(int bitflags)
        {
            DataFactory.Instance.SavedPage += LogSaved;
            DataFactory.Instance.PublishedPage += LogPublished;
            DataFactory.Instance.MovingPage += CheckIfDeleting;
        }

private static void LogSaved(object sender, PageEventArgs e)
        {
            LoggingTools.LogVersionStatus(e.Page, "Saved", "Details: Version saved.", EPiServer.Security.PrincipalInfo.Current);
        }

        private static void LogPublished(object sender, PageEventArgs e)
        {
            LoggingTools.LogVersionStatus(e.Page, "Published", "Details: Version published", EPiServer.Security.PrincipalInfo.Current);
        }

        private static void LogReadyToPublish(object sender, PageEventArgs e)
        {
            LoggingTools.LogVersionStatus(e.Page, "Publish Requested", "Details: Version marked as Ready to Publish. ", EPiServer.Security.PrincipalInfo.Current);
        }

}

This could be enhanced to log additional system actions..or be made more flexible so I’m only calling one Log procedure and then have some logic within to determine what the appropriate message should be… but you get the idea.

May 11, 2010

Comments

Please login to comment.
Latest blogs
Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog

The A/A Test: What You Need to Know

Sure, we all know what an A/B test can do. But what is an A/A test? How is it different? With an A/B test, we know that we can take a webpage (our...

Lindsey Rogers | Apr 15, 2024

.Net Core Timezone ID's Windows vs Linux

Hey all, First post here and I would like to talk about Timezone ID's and How Windows and Linux systems use different IDs. We currently run a .NET...

sheider | Apr 15, 2024

What's new in Language Manager 5.3.0

In Language Manager (LM) version 5.2.0, we added an option in appsettings.json called TranslateOrCopyContentAreaChildrenBlockForTypes . It does...

Quoc Anh Nguyen | Apr 15, 2024