Get one of those scrubbing tools from Park or Finish Line that has the rollers the chain runs through. You fill the tool with detergent and back pedal.
The other way is to take the chain off and put it in a tub with some detergent and agitate for a couple of minutes.
I'm not sure which way works best. They both have their merits and detractions. The one thing I know for sure is that Simple Green works exceptionally well as a detergent. I'm amazed at what that stuff can do.
I had my mechanic install a sram quicklink? so that I could remove chain easily. Scrubbing tools that Guy mentioned do work well also. But, I prefer to remove chain and let it soak in some neutral ph auto parts cleaner, agitating occasionally. Then I drop it in an inexpensive ultrasonic cleaner and cycle it several time with a citrus cleaner and then water. I clean chain every 30-40 miles.
I got a question, do you always clean chain before lubing, or do you re-lube chain before each ride, then clean occasionally? I would like to re-lube chain before each ride but I think lube might wash dirt into rollers if its not clean.
Good point about lubing after a ride. That way you're good to go and all the carrier has evaporated. Also, make sure if you use a citrus cleaner to rinse well with hot water to remove same. Otherwise your lube will "fling off" and you're left with bare metal.
After about 2 or 3 applications it will be cleaner than any solvents you can use. Just wipe the chain down good with a rag after every lube. You will never have to clean your chain again as the ProLink will clean and lube it better than anything.