Diplo Audit Log Viewer for Umbraco CMS Blog post

The Challenge

Those with long memories will remember that in Umbraco 4 there was an umbracoLog table that contained every change made in Umbraco - both to content (Save, Publish, Delete etc) and also trace data raised by Umbraco (exceptions, debug messages, startup info etc). Sometime in Umbraco version 6 the trace data was changed to use log4Net and logged to daily plain-text files in /App_Data/Log/ - and this led me to create perhaps my most popular package - Diplo Trace Log Viewer. But this splitting of audit and trace data into two different channels meant that there was still no easy way of viewing the audit data in the umbracoLog table - sure, you can view the audit trail for individual pages, but you can't view it all in one place. Well, not until now...!!! (OK, I believe other people have written log viewers for this table, but allow me a little hyperbole, please!).

The Solution

So my aim was to bring the same style interface that Diplo Trace Log Viewer has, but this time for viewing audit data - this includes every change every user makes - whether it be publishing a page, deleting some media, editing a content type or even installing a package. All that data is there, but not easy to access (unless you enjoy writing lots of SQL...)

One of the main differences between this and my other package is that all the data is stored in the database - this makes it easier in many respects (no need for 100+ character regexes to parse the file) but also raises a few challenges - you have to ensure the SQL you write works against both SQL Server and SQL CE (and maybe MySQL if anyone still uses that!). You also need to implement server-side pagination, since I know from experience the log table can grow to many thousands of entries. Luckily Umbraco's customised version of PetaPoco/nPoco allows easy pagination using the Umbraco.Core.Persistence.Page<T> class which works well in conjunction with the umbPagination Angular directive added in 7.4 to generate database-agnostic pagination.

Features

  • Filter log data by log type (Save, Publish, Delete etc)
  • Filter by user (ie. person responsible)
  • Filter by date or date range (ie. all audit events that occurred within a given period)
  • Filter by node (with easy to use content-picker)
  • Search the log data comments by keyword
  • Handy quick filters for the more common audit tasks
  • Uses fast, server side pagination of data so it should be quick no matter how large your log table has become
  • Angular interface that integrates with Umbraco
  • Quick "edit" links to users and content

Show Me The Screenshots

Showing the quick filters in the sidebar and the main interface and data on the right

Filters

Uses server-side pagination with an Angular directive

Pagination

Allows you to view more detail of each log entry

Log Detail

OK, Where Can I Get It?

You can download it from either NuGet (recommended) or via a traditional Umbraco package. And, of course, the source is freely available (but please give me a shout if you use it for anything interesting, K?).

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

Umbraco Package: https://our.umbraco.org/projects/developer-tools/diplo-audit-log-viewer/

Source Code: https://github.com/DanDiplo/Umbraco.AuditLogViewer 


12 Comments


Giovanni Sidoel Avatar

Hey Dan. I know it says "for 7.4>" obviously...but will it not work or break anything if I install on a 7.2? I have an older install that I would really like to use this for. Thanks!



Dan Diplo Avatar

I think it will partly work - but I'm not sure if the pagination will work, since I think that Angular directive was only added in 7.4. But it won't do any harm and you should be able to uninstall it if it doesn't work.


Roy van den Ekker Avatar

Hi Dan, First of all, great plugin! How do I cope with timezones? Everything is set to local timezone (CET), everything in the backoffice and database is in that timezone. But the log results seem to think server is in GMT, so it adds an hour. The query in SearchAuditLog returns local time. I am not an angular expert, but there doesn't seem to be a setting for that. Any suggestions?


Dan Diplo Avatar

Hi Roy,


Hmmm, it must be the Angular date formatting that's doing it, then. I'm using the standard Angular date formatting. Can you find the file App_Plugins\DiploAuditLogViewer\backoffice\diploAuditLog\edit.html and maybe try changing the date format:


{ l.DateStamp | date:'short' }}


to


{ l.DateStamp | date:'short' : 'UTC' }}

See if that works and let me know?


 


Roy van den Ekker Avatar

Hey Dan,


So far no luck, no matter what I try. Which timezone I tell it to be or as which timezone it should interpret the datetime. It shows +1:00 when I use "Z" for displaying.
No problem continuing using the plugin like this. You can always contact me at my email address if you have some ideas or want me to try something.



dan@diplo.co.uk Avatar
Hi Roy,

Sorry you've had no luck - why are timezones so complicated, eh? If I figure out a way around this I'll let you know.

Vince Avatar

Hi Dan,


Recently we try to install your plugin on our Umbraco instance, however, after installation, I encountered this kind of error: EXCEPTION DETAILS


System.NullReferenceException: Object reference not set to an instance of an object. STACKTRACE


at Umbraco.Web.Trees.ApplicationTreeExtensions. TryGetRootNodeFromControllerTreed__4.MoveNext() .... The Umbraco version is 7.4.3, running on .NET 4.5.1. Is there special setup required(I tried .NET 4.5.2)?


Thanks heaps


Vince


Dan Diplo Avatar

Hi Vince,


Sorry you had an issue. I believe it should work with any version of NET 4.5.x - though it was build with 4.5.2. I'm pretty confident the package works in standard Umbraco installs.


The error you are seeing seems to originate from Umbraco. I recall reading about similar errors on the issue tracker and forum relating to AutoFac - do you use it or a package that uses it?


Have a look at these and see if any help you:


Autofac: Failing to register Tree Controllers breaks all trees.


Tree error thrown after install when entering developer section.


Nuget package breaks developer tree


Let me know if any of these help...


 


 


 


 


 


Brett L. Avatar

Is there a content version differences view within each log item? For example, how do you know which fields and field values changed?


Dan Diplo Avatar

No, the audit log just shows the log entries in the umbracoLog table, it doesn't store or process the changes. If you want to see those, go to the individual item and use Umbraco's built-in audit viewer.


Gary M Avatar

Hello. We are running Umbraco 6.1.6 here. Will Diplo Audit Log Viewer work in v6?


Kind regards, Gary


Dan Diplo Avatar

Sorry, Gary, it only works with Umbraco 7.4 and up due to the way it uses Angular and other dependencies that were only added in that version.


The source code is on GitHub if you fancy a crack at modifying it for v6.


 

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.