我对 powershell 脚本很陌生。我想使用 out-gridview 在gridview 中显示一个日志文件。
假设我有一个非常简单的脚本,例如
$logFile = "logs\myCoolLogFile.log";
gc -wait $logFile | Out-GridView -Wait
这将在单个单元格中显示每一行。我的日志格式如下:
LEVEL TIMESTAMP LOGGERNAME [THREAD]: MESSAGE
每个条目由一个或多个空格分隔(但如果更合适,我可以轻松地将其更改为由一个制表符分隔)。该消息可能包含额外的空格。以前的条目从不包含空格。
我想有不同的列LEVEL
,TIMESTAMP
等等。但我不知道如何实现这一点。任何帮助表示赞赏。
编辑:根据@jisaak的要求,这是我的日志示例,其中包含多行消息:
WARN 09:53:49.938 n.s.e.CacheManager [StartStop-Thread] Creating a new instance of CacheManager using the diskStorePath "C:\temp" which is already used by an existing CacheManager.
The source of the configuration was net.sf.ehcache.config.generator.ConfigurationSource$DefaultConfigurationSource@48666bf4.
The diskStore path for this CacheManager will be set to C:\temp\ehcache_auto_created_1461052429938.
Edit2:现在,我想一想,如果完全跳过不包含足够列的行,我想这是可以接受的。但我也需要针对这种行为的帮助。