Log tailing in Windows

Linux and macOS have native tools which supports many of the log tailing functions. If you are one of unfortunate person who sometimes have to operate on Windows, consider this an enlightenment post

There are two core operations with most logfile use-cases

  1. Tailing live logfiles
  2. Extracting meaningful lines from live logfiles

Absence of tail and pipe in Windows, **used** to be the reason why Cygwin was installed to get those Win port commands. Not anymore.

First — stop installing Cygwin like its Y2K era. Windows has made great strides.

Here are 3 ways to to achieve it

  1. Baretail
  2. glogg
  3. PowerShell Hacks

Baretail and glogg are Windows based utilities. Both have neat functions. Baretail has pro version but free version should be good for the most cases. glogg is similar to Baretail. Both operate on large logfiles very fast. (As a policy, do an anti-virus/malware scan on any software you download)

PowerShell Hacks

In most corporate Windows, it is not easy to install and run third party software. If you do have access to PowerShell, here are some hacks how to do it in PowerShell.

List the contents of the logfile
Get-Content my_big_log_file.log

Tail the contents
Get-Content my_big_log_file.log -wait

Extract the error lines
Get-Content my_big_log_file.log -wait | where { $_ -match “error”}

Extract few lines above and below the error line
Get-Content my_big_log_file.log | Select-String -Pattern “error” -Context 3,2

Now, put it in a seperate file
Get-Content my_big_log_file.log | Select-String -Pattern “error” -Context 3,2 | Out-File -Endcoding utf8 error_messages.log

My logfiles contain UTF8 characters. If you have simple log then “> logfile.txt” should work.

Now you should be on your way, to faster debugging even in Windows.