Skip Navigation Back

Working with Sitecore logs can become rather tedious.  Sitecore generates quite a few different files, and new files are created each time the application restarts.  On a developer workstation, this can mean a lot of finding and re-opening logs.  Multitail allows for a consolidated view of the latest messages from all of the Sitecore log files, and automatically displays new log files as soon as they are created.

Multitail can also provide log highlighting via a customizable set of regexes. This can be helpful to quickly focus in on errors, warnings, etc.

Multitail highlighting

Setup:

  1. The first concern is that multitail is a Unix utility, whereas we do Sitecore development on Windows. Multitail supports Cygwin, but Windows 10 introduced an interesting alternative – Ubuntu Bash can be installed as a windows subsystem. Installation instructions.
  2. Once installed, open Bash and execute:
    • sudo apt-get install multitail
  3. You can now run multitail against the Sitecore logs directory with a command such as the one below.  This will automatically pull in the latest messages from all log files in the directory, and discover new files when they’re created.
    • multitail -Iw "/mnt/c/inetpub/wwwroot/sitecore_sample/Data/logs/*.txt"
  4. If you’re only interested in the main Sitecore log file (as opposed to search.log, etc.), you can limit the wildcard filter to ‘log.*.txt’
  5. If you are interested in the main Sitecore log, plus some custom logs, you can list multiple:
    • multitail -Iw "/mnt/c/inetpub/wwwroot/sitecore_sample/Data/logs/log.*.txt" -Iw "/mnt/c/inetpub/wwwroot/sitecore_sample/Data/logs/custom.*.txt"
  6. For highlighting, create a .multitailrc file in your home directory (e.g. nano ~/.multitailrc) and set up some highlighting rules. See below for a sample.  The first line defines the name of the scheme– “sitecore_log” in this case. You can then add ‘-CS sitecore_log’ to the multitail command to make use of the scheme:
    • multitail -CS sitecore_log -Iw "/mnt/c/inetpub/wwwroot/sitecore_sample/logs/notifications.*.txt
    • Sample .multitailrc file (adapted from http://smasue.github.io/multitail-logs):
      • colorscheme:sitecore_log
        cs_re:green,,bold:INFO
        cs_re:yellow,,bold:WARN
        cs_re:magenta,,bold:DEBUG
        cs_re:red,,bold:ERROR
        cs_re:red,,bold:FATAL
        cs_re:green:^.*INFO.*$
        cs_re:yellow:^.*WARN.*$
        cs_re:magenta:^.*DEBUG.*$
        cs_re_s:white,red:ERROR (.*)
        cs_re:red:.*
  7. To avoid having to retype the command each time you open Bash, add the following at the end of your ~/.bashrc file:
    • alias sitecorelogs='multitail -CS sitecore_log -Iw "/mnt/c/inetpub/wwwroot/sitecore_sample/Data/logs/custom.*.txt" 1 -Iw "/mnt/c/inetpub/wwwroot/sitecore_sample/Data/logs/log.*.txt" 1'
    • You can then invoke the command by the alias name: sitecorelogs

See the multitail manual for more information and features:

man multitail

Note: you are likely to see an error when running multitail: tail: unrecognized file system type 0x53464846 … please report this to bug-coreutils@gnu.org. reverting to polling. You can ignore this. There does appear to be a fix, but I haven’t looked into how it might be applied.

Some alternatives that I looked into before settling on multitail:

  1. Sitecore Rocks has a Log Viewer under Tools. However, it doesn’t deal with any custom log files you might introduce in the data\logs directory.  Its refresh rate is also rather slow – a minimum of ten seconds.
  2. There are a few Windows tail programs (e.g. SnakeTail), but I haven’t found one that will dynamically discover new files or will merge multiple files together.
  3. Powershell might be able to accomplish this with something similar to https://stackoverflow.com/a/35740166/578897
avatar
Author: Kevin Gregory

As a Technology Developer at Primacy, Kevin helps to bring innovative digital experiences to life. His areas of expertise include .NET and PHP development, JavaScript, web services and other web technologies.


Published June 2017

Category Technology

Tags
Comments