Question

I have the following LogParser 2.2 query that will look for all SMTP errors from the SMTP logs of our Exchange 2010 Hub Transport and output it to a SQL Server 2008 R2 database. This works fine but I would like to add the name of the log file that the error originated in as a field name (which would make tracking more details about the error much easier). Is there a way to include the log file name in the field list?

"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
Was it helpful?

Solution

In your selected columns, add Logfilename

You also might find LogRow useful.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top