Diplo Audit Log Viewer for Umbraco 7 CMS Blog post

Important Note

This is about the Umbraco v7 version of my Audit Log Viewer for Umbraco.

If you want the latest version for Umbraco v8 then please read Diplo Audit Log Viewer for Umbraco 8 instead.

If you want the version for Umbraco 10 then see Diplo Audit Log Viewer for Umbraco 10.

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/1.0.4

Umbraco Package: https://our.umbraco.org/projects/developer-tools/diplo-audit-log-viewer/ (use 1.0.4 version for Umbraco v7)

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


21 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.


 


nhat nguyen Avatar

Hi, Does this package support for Umbraco 7.4.0?


Dan Diplo Avatar

Yes, 7.4.0 is the earliest version it supports. Though I haven't extensively tested it with all versions.


The Donald Avatar

Loving the app, it's the greatest! I've never seen a better app, but, and this is a big butt! Can it build a wall? I need a firewall to help me with my plans for Net Neutrality. Really, seriously, great app, so let's Make Apps Great Again!


Francisco Avatar

Hi Dan, Does the pluggin has support for changes in members? I mean, if a member changes his data with a form in the web, Could I see it with the logs? and Could I see exactly what has he changed? Thanks.


Dan Diplo Avatar

Hi Francisco. The plugin just reads back the data that Umbraco logs to the umbracoLog table in the database. So I don't decide what that is - it's whatever Umbraco logs. But generally this is what back-end Editors change in Umbraco and not members, so I don't believe member changes are recorded by default. You might be able to hook into Umbraco's audit service and log your own changes in there - and then they'd show up in the viewer - but you'd need to do that yourself. See https://our.umbraco.com/apidocs/csharp/api/Umbraco.Core.Services.AuditService.html 


You might also find some member information is logged into the Umbraco trace logs - which are files. I have another viewer for this you can use to see that information - see https://www.diplo.co.uk/blog/web-development/diplo-trace-log-viewer-for-umbraco/ 


 


 


david Avatar

Hi Dan. Thans for awesome Audit Log Viewer and Trace Log Viewer! Are there any plans to support Umbraco version 8?


Dan Diplo Avatar

Hi David,


I do hope to support Umbraco 8 sometime in the future. I've made some tentative start on re-working it for v8. However, v8 has made a lot of changes under the hood, so it's not a simple port, and currently the v8 documentation is thin on the ground. But I'm confident it will appear at some point - but might not be for a while.


Reggie Avatar

Looks great. Two Questions. 1. How far back will it save data? 2. Can you click on an item to see the area that was changed or what change was made?


Dan Diplo Avatar

Hi Reggie,


It reads the data from the umbracoLog table in the database which is added to by Umbraco every time some content is changed. As far as I know this table goes back as long as the site has been in existence, though it is possible to manually clear this table.


You can click on an item to see details (as per this screenshot) but it can only display what is stored in the log table, which is the basic info you can see. It doesn't record what the actual change was. You can see those changes if you use the roll-back feature in Umbraco on a page, though.


 


 


 

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.