2013-10-10 22 views
1

我有以下LogParser 2.2查詢將從我們的Exchange 2010集線器傳輸的SMTP日誌中查找所有SMTP錯誤,並將其輸出到SQL Server 2008 R2數據庫。這工作正常,但我想添加錯誤發源的日誌文件的名稱作爲字段名稱(這將使跟蹤關於錯誤的更多細節更容易)。有沒有辦法在字段列表中包含日誌文件名?在LogParser中包含文件名作爲字段

"C:\Program Files (x86)\Log Parser 2.2\logparser.exe" 
"SELECT 
    'Prospect' as ExchangeServer, 
    'Receive' as SmtpType, 
    TO_LOCALTIME(TO_TIMESTAMP(STRCAT(STRCAT(EXTRACT_PREFIX(TO_STRING([#Fields: date-time]),0,'T'),' '),EXTRACT_PREFIX(EXTRACT_SUFFIX(TO_STRING([#Fields: date-time]),0,'T'),0,'.')),'yyyy-MM-dd HH:mm:ss')) as Timestamp, 
    connector-id as Connector, 
    EXTRACT_PREFIX(local-endpoint,0,':') as ServerIP, 
    TO_INT(EXTRACT_SUFFIX(local-endpoint,0,':')) as ServerPort, 
    REVERSEDNS(EXTRACT_PREFIX(local-endpoint,0,':')) as ServerName, 
    EXTRACT_PREFIX(remote-endpoint,0,':') as ClientIP, 
    TO_INT(EXTRACT_SUFFIX(remote-endpoint,0,':')) as ClientPort, 
    REVERSEDNS(EXTRACT_PREFIX(remote-endpoint,0,':')) as ClientName, 
    TO_INT(EXTRACT_PREFIX(data,0,' ')) as Error, event as Event, data as Data, 
    context as Context 
INTO SmtpLog 
FROM 'E:\Log Files\SMTP\Receive\*.LOG' 
WHERE (event = '>') and ((data LIKE '5%%') or (data like '4%%'))" 

-i:CSV -nSkipLines:4 -o:SQL -server:DbServer -database:DbName -createTable:ON -clearTable:ON 

回答

4

在你選擇的列,加LOGFILENAME

您也可能會發現LogRow有用。

+2

謝謝! LogFileName和LogRow字段名稱對CSV文件不正確,但當我嘗試它們時,錯誤消息給了我正確的。輸入格式爲CSV(-i:CSV)時,請使用字段'文件名'和'行號'作爲參考。 – Caynadian

相關問題