What
@dave ensign said was brought to bear in a lesson well learned.
One key way to prolong the sharpness of your chain is to be mindful of dirt/stones, etc. The part of the lesson that I want to pass on is that while bucking, make sure that you are cutting through a clean log. In other words, if any part of the log was dragged in dirt, sand etc, do all you can to debark any areas that you see have that gunk in it. These will dull and wear on your chain the same as hitting the dirt. Also, in case you think that debarking is too much work, It really only has to be the areas directly in line with the saw kerf, not the whole log debarked.
As far as sharpening, learn from what the others have said here.