We used to use our log files for all sorts of things, but as they got
too big to handle, we resigned to simply using a commercial tool to
analyze them for us and give us the highlights. Well, there are
times when there's information in those files that you really need and
just the highlights just won't do. On the other hand, trying to find
the right entries is like looking for a needle in a haystack.
For occasions such as this, I occasionally use the AppendToLog
method to assist in finding the appropriate entries.
For example, lets say there's an intermittent problem with a page
and you want to find out something about it. Your log files can tell you
how long the request took to process, the cookies
sent with the request, the status codes returned, or even the bytes sent
in and out. Some of this information might be invaluable in
troubleshooting this problem, but how do you associate a given request
with an instance of the problem? It's easy... you append some sort of
unique identifier to the log file line by using the AppendToLog method of the
Response object.
You can append any string under 80 characters to the entry for the current
request. It can't contain commas since log files are comma delimited, but
beyond that you've got free reign. You could do it only in your error handling
to log additional troubleshooting information or maybe only for users from
a particular IP address. It's up to you. As I mentioned above it can even
be helpful to simply log anything that you wouldn't normally find in your
log files (like a pet's name or even your favorite quote) just to make it
easy to find the right records.
It might not solve all your problems, but at least the haystack is
smaller and the needle is shiny. ;)
If you have a tip you would like to submit, please send it to:
webmaster@asp101.com.