powershell - Use Out-gridview to display Log -
i'm pretty new powershell scripts. i'd display log file in gridview using out-gridview.
let's have simple script
$logfile = "logs\mycoollogfile.log"; gc -wait $logfile | out-gridview -wait
this displays each row in single cell. log formated this:
level timestamp loggername [thread]: message
each entry separated 1 or more spaces (but can change separated 1 tab character if more suitable). message may contain additional spaces. previous entries never contain spaces.
i'd have different columns level
, timestamp
etc. i'm not sure how achieve this. appreciated.
edit: @jisaak requested, here example of log multi line message:
warn 09:53:49.938 n.s.e.cachemanager [startstop-thread] creating new instance of cachemanager using diskstorepath "c:\temp" used existing cachemanager. source of configuration net.sf.ehcache.config.generator.configurationsource$defaultconfigurationsource@48666bf4. diskstore path cachemanager set c:\temp\ehcache_auto_created_1461052429938.
edit2: now, think it, guess acceptable if lines not contain enough columns skipped altogether. need behavior well.
you can use convertfrom-csv cmdlet convert log:
$logfile = "logs\mycoollogfile.log"; gc $logfile | convertfrom-csv -delimiter ' ' | out-gridview
why using -wait
switch on get-content
cmdlet?
Comments
Post a Comment