Our company has a bunch of custom server applications that all write logs that include the date in the filename. For example, the filename for the 7th might be ServerApp1_07.txt. The out-of-the-box Log Parser template can only handle static filenames.
I am sure there are other products that create dated log files so I added a couple lines to the Log Parser scripts that allow it to build a file path based on the current date and a format provided as an argument.
The new format for arguments is:
Base file path,date format, file extension, regex
For example:
\powertest_,dd,txt,string
will search for "string" in the file
\powertest_01.txt on the 1st of the month,
\powertest_02.txt on the 2nd, etc.
NOTE: The scripts do not validate the date format argument. Make sure that yours is correct. See the following MSDN article for more information: https://msdn.microsoft.com/library/system.globalization.datetimeformatinfo.aspx#properties
The changes were that this:
# Arguments example: d:\powertest.txt,string<br />$logfile_path = $args.get(0);<br />$regex = $args.get(1);<br />$Error.Clear();
became:
# Arguments example: d:\powertest_,dd,txt,string<br />$logfile_base = $args.get(0);<br />$date_format = $args.get(1);<br />$file_extension = $args.get(2);<br />$regex = $args.get(3);<br />$date_to_append = Get-Date -format $date_format;<br />$logfile_path = $logfile_base + $date_to_append + "." + $file_extension<br />$Error.Clear();
in the Total number of strings found and Number of newly found strings monitors. The Found string in # position script has an additional argument for the position which remains the last argument. Otherwise the changes were the same.