1

我有以下 LogParser 2.2 查询,它将从我们的 Exchange 2010 集线器传输的 SMTP 日志中查找所有 SMTP 错误,并将其输出到 SQL Server 2008 R2 数据库。这工作正常,但我想添加错误源自的日志文件的名称作为字段名称(这将使跟踪有关错误的更多详细信息更容易)。有没有办法在字段列表中包含日志文件名?

"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

1 回答 1

4

在您选择的列中,添加 Logfilename

您还可能会发现 LogRow 很有用。

于 2013-10-11T16:23:42.493 回答