Author Posts

July 4, 2016 at 9:58 am

Hi,

I have a log file, which contains the below information:

ERROR 2016-07-03 23:30:57,338 schedulerFactory_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus – ##################### Aggregation Status #########################
ERROR 2016-07-03 23:30:57,338 schedulerFactory_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus – ####### Aggregation Start Time – 2016-07-03 22.30.00
ERROR 2016-07-03 23:30:57,338 schedulerFactory_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus – ####### Aggregation End Time – 2016-07-03 23.30.57
ERROR 2016-07-03 23:30:57,338 schedulerFactory_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus – ####### Total Duration took to drop index – 876
ERROR 2016-07-03 23:30:57,338 schedulerFactory_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus – ####### Total Duration took to recreate index – 17468
ERROR 2016-07-03 23:30:57,338 schedulerFactory_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus – ####### Total Number of tables aggregated – 292
ERROR 2016-07-03 23:30:57,338 schedulerFactory_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus – ####### Time taken for whole process – 3657330
ERROR 2016-07-03 23:30:57,338 schedulerFactory_Worker-9 com.efi.printsmith.franchisee.util.AggregationStatus – ##################################################################

I need to get only Aggregation Start Time – 2016-07-03 22.30.00, Aggregation End Time – 2016-07-03 23.30.57, Time taken for whole process – 3657330 to a text file.

-Kalyan

  • This topic was modified 2 years, 1 month ago by  Venkata Kalyan. Reason: Subject wrong

July 4, 2016 at 3:29 pm

$log = Get-ChildItem \\path\to\logfile
$results = switch -Regex -File $log {
    'Aggregation (Start|End) .*' {$Matches[0]}
    'Time taken .*' {$Matches[0]}
}

$results | Out-File \\path\to\logresults.txt

July 6, 2016 at 3:55 am

Thanks.

-Kalyan