Sorting 使用powershell从不同的服务器按日期/时间进行Coallate日志

Sorting 使用powershell从不同的服务器按日期/时间进行Coallate日志,sorting,powershell,logging,Sorting,Powershell,Logging,我想要一个脚本,它从路径列表中获取日志,并将日志中的所有条目排序到一个大型合并日志中。我对编程和powershell相当陌生,但我已经有了一个开始。日志条目如下所示: 2013-07-17 05:00:00003信息[com.mpi.mp.viewer.web.servlet.ViewerLogFlusher]跳过了将空字符串发送到wmsiislo的过程 我的想法是,我需要以某种方式将每一行解析为多维数组,并对其进行排序。问题是,我无法掌握[DateTime]方法的诀窍。我非常不完整的代码如下:

我想要一个脚本,它从路径列表中获取日志,并将日志中的所有条目排序到一个大型合并日志中。我对编程和powershell相当陌生,但我已经有了一个开始。日志条目如下所示:

2013-07-17 05:00:00003信息[com.mpi.mp.viewer.web.servlet.ViewerLogFlusher]跳过了将空字符串发送到wmsiislo的过程

我的想法是,我需要以某种方式将每一行解析为多维数组,并对其进行排序。问题是,我无法掌握[DateTime]方法的诀窍。我非常不完整的代码如下:

#Code to append all logs together

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

}
试试这个:

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