In which situation is it appropriate to write using informal language

A postcard for a friend
A cover letter for job application
A scientific research article
A legal document to present in court

It is appropriate to write using informal language in a postcard for a friend.