Diplo Audit Log Viewer for Umbraco 8 Blog post

A Little History

Way back in 2016 I created a package for Umbraco 7 that allowed you to view the contents of the umbracoLog table. You can find more about that in the blog post I wrote at the time. With the release of Umbraco 8 earlier this year (2019) I decided it was time to start looking at moving some of my packages over to v8 and decided this package would be a good choice. However, I hadn't reckoned on just how much in v8 had changed - especially in terms of working with the more low-level aspects of Umbraco, such as using the back-office services and interacting with databases. So what started out as a simple port became a wholesale rewrite! If you are a developer, I'm sure you are familiar with this!

So What Does It Do?

Basically if you install the package you will get two new trees in the Settings section of Umbraco within the Third Party area, like this:

Audit Tree in Settings

The Content Audit Logs tree allows you to view, filter, search and paginate through all the umbracoLog table entries. This is the log of all changes to content that is made in Umbraco.

You can filter by:

  • The type of content change eg. Save, Publish, Delete etc.
  • The user who performed the change
  • The content node that was changed (using a handy page picker)
  • Date range
  • You can also perform a free-text search of the log contents

Where a change affected a content node then the Id of the node is shown along with it's content type (eg. Document, Media, Member) and clicking the Id of the node will take you directly to edit the content. This works for content, members, media, document types, data types etc.

The Audit Trail Logs tree allows you to view, filter, search and paginate through all the umbracoAudit table entries. This is the log of all audit events, such as log-ins, changes of password or where a User changes the actual document types or member types etc.

You can filter by:

  • The type of event eg. umbraco/user/sign-in/login
  • The user who performed the action
  • The user who the action was performed upon (if relevant)
  • Date range
  • You can also perform a free-text search of the log contents

For both logs you can order the data by the relevant column by clicking it (clicking it again reverses the order). You can also step through the entries via the pagination controls.

Screenshots

As Leonardo da Vinci once said, "A screenshot is worth a thousand pizzas"...

Content Log Viewer

Content Log

Filtering By User and Searching

Content Log Filtering

Audit Log Viewer

Content Log

Filtering Audit Log by Date

Audit Log Filtering by Date

What's New for v8

So without going into loads of technical detail, I decided to rewrite most of the code so:

  • I used dependency injection to register my services (using Composing) so they could be injected in the API controllers
  • I used interfaces for the services (so in theory you can swap them out for your own implementation if you really want!)
  • I rewrote the database access code to work with Umbraco 8's implementation of NPoco - this has changed a lot from v7 and isn't documented anywhere!
  • I rewrote most of the AngularJS code in line with the way Umbraco recommend
  • I restyled the views to match Umbraco 8 styling
  • I added a brand new viewer that allows you to look at the new(ish) umbracoAudit table that was added at some point in late v7

How Do You Use It?

You can install it either via NuGet or as a package from Our Umbraco. See full details below.

Viewing Content Logs

  • Click the Content Audit Logs tree heading to view a table of all changes to content.
  • You can then use the filters at the top to filter the data. You can also use the quick filters in the tree to quickly filter by date range or by the top pages to be modified recently.
  • You can order any column by clicking on it's heading. Clicking again reverses the order.
  • If you see an entry with an "eye" symbol next to the Action name you can click the row to view the log comment text.
  • If an entry has a value under the Node column you can click the ID and it will take you to edit the associated content that has been changed - whether this be a page, a document type or media etc.
  • Use the pagination to move between pages of log data.

Viewing Audit Logs

  • Click the Audit Trail Logs tree heading to view a table of all audit trail events.
  • You can then use the filters at the top to filter the data. You can also use the quick filters in the tree to quickly filter by date range.
  • You can order any column by clicking on it's heading. Clicking again reverses the order.
  • Use the pagination to move between pages of log data.

Where Can I Get It?

NuGet: https://www.nuget.org/packages/Diplo.AuditLogViewer/

Packagehttps://our.umbraco.com/packages/developer-tools/diplo-audit-log-viewer/

GitHub: https://github.com/DanDiplo/Umbraco.AuditLogViewer

Note: This is for Umbraco 8 only! If you need a version for Umbraco v7 then please go here instead


11 Comments


Peter Duncanson Avatar

Excellent work Dan. To me this should be in core. It’s such a useful package. Great work.


Thomas Hansen Avatar

Really nice !


Thomas Kold Avatar

Can you also delete entries?


Dan Diplo Avatar

Hi Thomas,


No, I'm afraid you can't delete entries and you probably shouldn't be able too, either, since it does represent an audit trail of changes. Generally an audit trail should be immutable.


MasLoo Avatar

Hi there! That's a nice package. I'm curious if deleting records from umbracoAudit table using sql query causes any issues on website?! 'cause I queried DB and there was no relationship between umbracoAudit and other tables. I thought it's a good idea to remove unwanted data when it grows in shared hosts. This is what I've done with umbracoLog table and website is working properly without issue.


Dan Diplo Avatar

Hi MasLoo! It won't do any harm to your Umbraco site if you do delete some or all of the contents of the umbracoAudit ​table (I've done this myself). The only thing I'd be aware of is that this stores a record of what actions have been taken, so if you delete it, then you lose that record. But it can be prudent to prune the table of records that are years old and no longer relevant - it depends on how important maintaining the history is. But it won't harm anything if you do so.


MasLoo Avatar

Thank you Dan. According to the point you mentioned, I should keep records related to last month and remove the rest to reduce the risk of loosing important changes.


Brittany Devereux  Avatar

Hi Dan! I love this package and its perfect for a recent requirement that has been put forward to me, but the only thing is the "editors" umbraco group are the ones who wish to utilise it and they do not have access to the settings page by default. Would you be able to suggest an elegant way that it may be possible to: a)move this into the content section as a plugin extension or b) find a way to give editors access to this page.


Dan Diplo Avatar

Hi Brittany,


I was led to believe that the Audit log could contain sensitive data, so it should only be for admins. Obviously you could grant editors access to the Settings section in Umbraco, but that probably isn't a good idea given a lot of it shouldn't be modified by non-technical people.


I think the only way to change it would be to modify the source code and build a custom version. You'd need to modify the two Tree Controllers:


ContentLogTreeController.cs


AuditTrailTreeController.cs


Then change wherever it has Constants.Applications.Settings to Constants.Applications.Content or whatever section you required.


 


Kamal Hamzat Avatar

Hi Dan, Is there a way to set the Audit Log Viewer time to 24 hours format instead of 12 hours format. With the 12 hours format it is not clear to differenciate between 03:00am and 03:00 pm The time format in umbraco 7 is 24 hours format. Thanks. Kamal


Dan Diplo Avatar

Hi Kamal,


I use the built-in AngularJS date filters to display dates. You can read up on these here:


https://docs.angularjs.org/api/ng/filter/date


You'd have to edit the Angular views and then change the format string in the file to your preferred format. It would be these files:


/App_Plugins/DiploAuditLogViewer/backoffice/diploAuditTrail/edit.html


/App_Plugins/DiploAuditLogViewer/backoffice/diploContentLog/edit.html


So you could locate them in the /App_Plugins/ folder in Umbraco and update them.


Hope that helps a bit?


 

Just fill in the form and click Submit. But note all comments are moderated, so spare the viagra spam!

Tip: You can use Markdown syntax within comments.