Love My Love

how to export exchange logs to csv by logparser


You can download logParser from microsoft :

# 1. In short, run:

LogParser "select [#Fields: date-time] as date, sender-address, recipient-address, recipient-count, return-path, client-hostname, client-ip, server-hostname, server-ip, original-client-ip, original-server-ip, event-id, total-bytes, connector-id, message-subject, source into C:\ExChange\log_all\result.csv from C:\ExChange\log_all\MessageTracking\*.LOG" -i:CSV  -headerRow:on -nSkipLines:4

code above can export all logs to one csv file.

  • -nSkipLines:4 : filter 4 lines at begin.the log files’ first 4 lines is the head of file,no need for export.
  • [#Fields: date-time] as date : style like #Fields: date-time is complex title for csv, make it like [#Fields: date-time] can get the true info from log files.

# 2. how to get the right titles?

LogParser "select TOP 1 * into C:\ExChange\log_all\result.csv from C:\ExChange\log_all\MessageTracking\MSGTRK.LOG" -i:CSV  -headerRow:on -nSkipLines:4

Refer :