Auto reload Sitecore logs with Baretail

Auto reload Sitecore logs with Baretail

If you like to use Baretail as a log viewer, but hates having to open a new file whenever Sitecore rolls out a new log file, then stick with me in this blog post.

What is Baretail?

Baretail is a free real-time log file monitoring tool. It has some nice features such as real-time file viewing, follow tail mode, tail multiple files, configurable highlighting and it is a single small executable - no installer needed.

You can download Baretail from

Baretail does not support auto reloading new log files. When Sitecore rolls out new log files, you have the hassle of manually opening the new file on Baretail. Enters the Powershell script to solve this problem.

A brief explanation of the script

This script uses the System.IO.FileSystemWatcher class, which listens to the file system change notifications and raises events when a directory, or file in a directory, changes. Next, we are going to use the Register-ObjectEvent cmdlet. This cmdlet subscribes to events that are generated by .NET objects on the local computer or on a remote computer.

I will also use the Action parameter from the Register-ObjectEvent cmdlet to specify actions to take when a subscribed event is raised. In this case, it will reload Baretail with the new added log files.

Finally, I created an additional script to cancel the subscription. I use the Unregister-Event cmdlet, which deletes the event subscriber from the session.

Start monitoring the logs

The script below will monitor the logs directory and reload Baretail with the latest modified files whenever a new log file is created. Notice that, in the Open-Baretail function, I’ve specified the path to the Baretail executable. You should adjust it according to your own setup.

How to use it

.\"[Sitecore] Start log tail with Baretail.ps1" -Path "C:\inetpub\wwwroot\site\\App_Data\logs" -Log

The following are switch parameters you can use to enable/disable what logs you want to watch: Aggregation, Client, ContactMergeDataUpgrade, Eds, Fxm, Owin, Spe, Crawling, Log and Publishing.

Here’s another example:

.\"[Sitecore] Start log tail with Baretail.ps1" -Path "C:\inetpub\wwwroot\site\\App_Data\logs" -Log -Eds -Owin -Client


Photo by Dids from Pexels.

comments powered by Disqus

Read more