Tailing Umbraco log files with Windows PowerShell

I've read a few people looking for an alernative to the Umbraco trace to help them to debug when using the new Umbraco MVC rendering engine.

The wonderfully named umbDebugShowTrace query string has no effect when using the MVC rendering engine - because the information that it provided isn't available. As discussed in my previous blog post we now have log4net available in Umbraco.

In the previous post I shared tips on how to place your own debug messages in their own log4net file - but for the predominantly lazy (I include myself in this group) there is a simple Powershell command to help out:

cat UmbracoTraceLog.txt -wait | select-string "string to find"

To break this down cat UmbracoTraceLog.txt just dumps the contents of the Umbraco log file to the console (cat is an alias of the Get-Content Cmdlet). The -wait flag keeps the command running appending new output to the console as it is added to the file.

Lastly we can pipe the output of the command to it is filtered only to lines that contain specific text | select-string "string to find" - this could be the name of a particular class or namespace that you wanted to watch.

Note: "string to find" can be a regular expression if you want to do complicated inclusion or exclusion of log messages.

The output you get looks something like this:

Tailing Umbraco log files with Windows PowerShell

If you have a dual screen setup it works nicely to have your browser on one screen and this one the other.


Leave a comment