Tuesday, August 10, 2010

On the importance of logging...

Today I fought with an issue for hours. I have a Silverlight frontend that calls a WCF service to edit a file. Everything worked in debug mode, but once deployed, it only worked for about half the people that tried it, with no obvious correlation between them.

I kept thinking that the issue was with the service.  After all, I'd seen errors similar to this. Maybe it's some permissions thing.  Maybe the binding or behaviors aren't set properly.  Maybe the client config isn't set up right.

And maybe I was chasing my tail.  I was about ready to quit when a colleague suggested actually using the logging service we set up.  So I put debug logging messages in at each point in the flow.  Guess what?  The service was never even being called.  The issue was happening before the service call.

It was a stupid, simple issue that should have never been there in the first place.
contactList.Single(x => x.Address == userEmailAddress).Timestamp = DateTime.Now;
Should have been
contactList.Single(x => x.Address.ToLower() == userEmailAddress.ToLower())
.Timestamp = DateTime.Now;

side note: How silly is it that some people in the same company have email addresses with a different case?  We tested this on six people.  Three of the people had lower case domain names in their email (like @gmail.com).  The other three had capital letters (@GMAIL.com).  Ugh.

Simple little things like this can ruin your day. My colleague called this an "object lesson." Use logging. Set it up so that you can put debug messages everywhere, and just flip a bit in the config file to stop logging them, but continue to log errors.

No comments:

Post a Comment

Speak your mind.