How and when to mention negative conditions or complaints in a resignation letter.
Bringing up a complaint in a resignation letter is tricky. On the one hand, it can be important for your (former) employers to know why you're leaving if it can help them make their company better or safer. On the other hand, a vindictive former employer can use your own words against you and make it difficult to find work elsewhere. As such, it is best to be polite and brief, but to include negative feedback when the risk is worth it.
When deciding whether or not to include negative feedback in a resignation letter, one thing to consider is your own future circumstances. If you will not need your former employer as a reference (you have another job lined up, you're retiring, etc.), negativity won't be such a potential danger. If you're relying on your former employer to put in a good word for your next application, use caution. Even saying something as innocuous as "I have enjoyed my time here but need to find work that causes me less stress" could be used to argue that you don't have stamina, that you're unsuited for certain positions, or that you can't tough out difficulties in your field.
Another question is how much you like and trust your boss. If you feel like your employer will be understanding, sympathetic, and open to criticism, the resignation letter can be a conduit toward productive feedback. Many employers want to hear the truth, and may be less inclined to give you a good reference if they feel like you quit for no reason. If that's the case, however, it's still best to air the grievance during an exit interview. A resignation letter often goes in your file, and you don't know how it will be used after that.
Finally, one of the most important questions to consider is whether including negativity in your resignation will have a positive impact. Bringing up hazardous work environments, low pay, long commutes, harassment, or overwork might not put you in your employer's good graces-but it might spark change within the company, especially if they have a high turnover rate. Giving feedback that the environment is driving employees away may help them identify the problems and work toward fixing them.
Additional note: While it is possible that airing a grievance in a resignation letter will convince your boss to fix it (or give you a raise, or give you a promotion) in an effort to keep you with them, it's a risky move. It's better to bring up the grievance with your supervisor (or HR) before you decide to resign. If they do nothing, and you feel you can't work in those negative circumstances, feel free to bring it up in your resignation letter as a final ploy. However, chances are good that they'll just let you leave, so be prepared to follow through with your resignation.