2013-10-10 4 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) 인 경우 참조 용으로 'Filename'및 'RowNumber'필드를 사용하십시오. – Caynadian

관련 문제