A formal grievance was a way for Starfleet officers to express their concerns to their commanding officers and request that they be addressed. An officer usually did this when they wanted both their grievance and the response to it on the record for the future. Someone might also file a formal grievance if they felt that the commanding officer might not otherwise take their concerns seriously.
In 2376, The Doctor on the USS Voyager filed a formal grievance with Captain Kathryn Janeway regarding his perceived disrespectful treatment by other members of the crew, as well as his proposal for the creation of an Emergency Command Hologram. Protocol allowed that either Commander Chakotay or Lieutenant commander Tuvok could answer the grievance if Janeway chose, but Janeway chose to reply herself. Though initially Janeway was skeptical, she eventually promised to form a research project to study his proposal. (VOY: "Tinker Tenor Doctor Spy")