Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

November 28, 2005 12:00 AM

Get a Load of Log Parser

This free data-collection utility is an Exchange admin's dream come true
Windows IT Pro
InstantDoc ID #48414
Rating: (3)

Does having access to a variety of valuable Exchange Server-related data sources, including the Windows event log, the system registry, Active Directory (AD), and Exchange Server message-tracking logs sound like a wish come true? Then Log Parser is the tool for you. This free Microsoft utility can quickly interrogate those data sources and output results in a variety of formats, including plain text, HTML, charts, or data that you can easily import into a Microsoft SQL Server database. Read on to find out how you can use this fast, powerful, and flexible utility to extract information about your Exchange servers' messaging traffic.

Using Log Parser
You can download the Log Parser kit from the Microsoft Web site (http:// www.microsoft.com/downloads/ details.aspx?familyid=890cd06b-abf8-4c25-91b2-f8d975cf8c07&display lang=en). The rudimentary installation procedure, which typically takes less than a minute, creates the Log Parser 2.2 directory under \program files. This directory contains all the Log Parser files, including the logparser .exe executable. If you've ever used SQL, Log Parser will be familiar. For example, to count all the messages received on the local server, I used the following command:

logparser "SELECT COUNT(*) FROM 
	C:\temp\server.log 
	WHERE [Event-ID] = 1028" -
i:W3C 

This command generated the output that Figure 1 shows. All I asked Log Parser to do is to count the number of records in the log file (i.e., C:\temp\server.log) to which I pointed the utility. You can pass parameters such as c:\logs\*.log to instruct Log Parser to process all the message-tracking logs in a directory. In the previous example, Log Parser looks for records with an event ID of 1028, which is the identifier that Exchange writes into the message-tracking log when it delivers a message to a local mailbox on a server. The -i:W3C parameter tells Log Parser that the input file is in World Wide Web Consortium (W3C) format. This speedy utility can process even very large message-tracking logs in a flash: When I ran this sample command, Log Parser processed more than 1,000,000 records in 16.5 seconds.

Task 1: Who Gets the Most Mail?
Let's execute a more sophisticated (and useful) query. You can use Log Parser to look for the top 10 recipients of messages delivered to mailboxes on the server.

First, you need to know which fields exist in the source logs. You can ask Log Parser to parse a file and report what it finds:

logparser -h -i:w3c 
	C:\temp\tracking.log 

Log Parser treats fields in message-tracking logs as either strings (S) or integers (I). Listing 1 contains a query that collects 1028 events and groups those events by recipient. That query is obviously more complex than the others and wraps over several lines in a command window. For the purpose of debugging and ease of use, it's more convenient to create such queries in a text file that you can then feed to Log Parser by passing the name of the text file as a parameter. Notice also that in the query that Listing 1 shows, I've taken the liberty of including a logs parameter that lets me specify the location of the input logs (i.e., C:\temp). So, to simplify the process, I can save the complete query into a file called recipients.sql, then execute the query by running the following command:

logparser
 file:recipients.sql?logs=
 c:\temp\*.log -i:w3c 

Figure 2 shows the resulting output.

By default, Log Parser outputs results to the screen, pausing output after every 10 lines. You can pipe the output to a text file by including the following syntax at the end of the query command:

C:\temp\output.txt 

Note, however, that when you send the output for this query to a file, there's no point in specifying anything other than "TOP 10" in your query as Log Parser pauses after every 10 lines and the command will never finish.

Let's refine things a little more. Take another look at Figure 2. Notice the entry for Server-IS@xyz.com; this is the address of the local public folder replication agent. I might want to know how many incoming replication messages arrived on the server, but I'm more interested in the activity of real people, so I need to exclude public folder replication messages. To do so, I can tell Log Parser to exclude any message sent to an address that includes the string -IS@, as callout A in Listing 2 does.

Now that we know who our top recipients are and how many messages they each receive, what other information do we need? How about the total size of those messages? We can tweak our query to compute the size of the total bytes field that Exchange logs for each message. Reporting the size in megabytes is more useful than reporting it in bytes; we can use a combination of Log Parser's DIV and SUM commands, then divide the computed value by 1048756 to get the result in megabytes, as Listing 3 shows. Figure 3 shows the results.

Looking at the output, we can see that one recipient—alerts@xyz.com— is receiving a much smaller total message size than the others. This recipient is likely a special mailbox used to receive notifications from an administrative process. Exchange generates a separate 1028 event for each recipient of a message; an individual message might have 20 or more recipients on a server, all of which result in separate 1028 events in the log. The fact that an individual message can feature in multiple events isn't a problem when we analyze message recipients, but it can be when we want to analyze message senders. We can use Log Parser to tackle that issue as well.

Related Content:

ARTICLE TOOLS

Comments
  • Anne
    4 years ago
    Jul 09, 2008

    The missing listings have been restored.

  • Anne
    4 years ago
    Jul 08, 2008

    Thanks for alerting us to the problem of the missing listings. I will report it to our web team and get it fixed ASAP. Thanks for reading!

  • Nurse
    4 years ago
    Jul 08, 2008

    Listings 4, 5 and 6 were extremely useful. Unfortunately, Listings 1, 2, and 3 are missing. Can they be put back?

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.