We use BareTail a lot, since it’s so fast and easy to work with, even on very large log files.
To make is easier for ourselves, we created some (batch) scripts to quickly open our log files using BareTail.
Our template for such a batch script is shown below, maybe it can be useful for others:
@echo off@rem example to connect to network share@net use "\\<ip-adres>" /d@net use "\\<ip-adres>" /USER:<username> "<password>"rem add the full path to the baretail executable as a system variablerem go to Start -> Run -> control Sysdm.cpl,,3 -> Environment variables -> new -> name: baretail, value: C:\Program Files\BareTail\baretail.exerem or use 'setx baretail C:\Program Files\BareTail\baretail.exe'rem if the env variable is not set, the default value will be used.@if "%baretail%" =="" set baretail=C:\Program Files\BareTail\baretail.exerem add all log files to be opened in list below, delimited with a space@set files=\\<ip-adres>\<path-to-log-file> \\<ip-adres>\<path-to-log-file>@start "baretail" "%baretail%" %files%@echo on
To easily tail all log files in the current directory:
setlocal ENABLEDELAYEDEXPANSIONif "%baretail%" =="" set baretail=C:\Program Files\BareTail\baretail.exeSET FILES=for /f "delims=" %%i in ('dir /a-d/s/b "*.log"') do SET FILES=!FILES! "%%i"start "tail" "%baretail%" %files%
Easily clear up all log files in the current directory by moving them into a WinRAR archive:
@echo offSET WIN_RAR_APP=c:\program files\winrar\rar.exeSET BACKUP_LOGS_DIR=backup_logssetlocal ENABLEDELAYEDEXPANSIONSET FILES=for /f "delims=" %%i in ('dir /a-d/s/b "*.log"') do SET FILES=!FILES! "%%i"mkdir "%BACKUP_LOGS_DIR%"SET Today=%Date: =.%SET Today=%Today:~-4%.%Date:~-7,2%.%Date:~-10,2%SET Now=%Time: =0%SET Now=%Now::=.%set archivename="logs_%Today%-%Now%.rar"set archivename="%archivename: =%""%WIN_RAR_APP%" m "%BACKUP_LOGS_DIR%\%archivename%" %files%
Update 26/04/2009: added scripts for logs in current directory.
No comments:
Post a Comment