2013-07-18 38 views
0

我想有一個腳本抓取路徑列表中的日誌,並將日誌中的所有條目分類到一個大的整合日誌。我在編程和PowerShell方面相當新,但我已經有了一個開始。日誌條目是這樣的:煤炭日誌/時間,從單獨的服務器,與PowerShell日誌/時間

2013年7月17日05:00:00003 INFO [com.mpi.mp.viewer.web.servlet.ViewerLogFlusher]跳過發送空字符串wmsiislo

我我的想法是,我需要以某種方式將每行解析爲一個多維數組,並對其進行排序。問題是,我無法得到[DateTime]方法的掛起。我很incomplerte代碼如下:

#Code to append all logs together 

$Biglog = Get-Content C:\Temp\logs\server1.log 
foreach ($line in $Biglog){ 
#do something 

} 

回答

0

試試這個:

ls c:\temp\logs\*.log | gc | out-file c:\temp\log.txt 
Import-Csv C:\temp\log.txt -Header "date","info" |Sort-Object date | export-csv c:\temp\sortedlogs.csv