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.Setup:
- 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.
- Once installed, open Bash and execute:
sudo apt-get install multitail
- 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"
- 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’
- 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"
- 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:.*
- 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
man multitailNote: you are likely to see an error when running multitail: tail: unrecognized file system type 0x53464846 … please report this to bug-coreutils [at] 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:
- 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.
- 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.
- Powershell might be able to accomplish this with something similar to https://stackoverflow.com/a/35740166/578897