Sefer Chofetz Chaim Chapter 4 first half of Halacha 2

One is forbidden to tell anyone else about sins that other people do or the fact they don’t perform mitzvos, whether referring to sins or mitzvos that everyone knows about or those which people don’t take seriously and don’t understand the severity of the law. He gives two examples of mitzvos not taking seriously, Torah learning and lying. The reason why one cannot tell other that another is lax in these matters even if those listening might not take them seriously is because they will now look at the person being talked about in a different light for now on. The Chofetz Chaim makes a very important differentiation. A person who transgresses a mitzvah out of spite, purposefully not having fear of Hashem is considered “not part of your nation” meaning even if he is biologically Jewish or converted to be Jewish but if he is purposefully rebelling then it is permissible to speak lashon hara about him, but most times than not people just make up excuses of why they do things wrong and a person who just sins or doesn’t do a mitzvah because of some excuse, no matter how lame it is you cannot tell anyone what he did, that would constitute lashon hara in most cases.

There is one Gemara in Bava Basra 111b where it seems that Rebbe Yannai spoke lashon hara about Rebbe Yehuda HaNasi to Rebbe Samlai in front of Rebbe Yehuda HaNasi’s face which might be worse because of embarrassment. Rebbe Yehuda asked Rebbe Yannai a question and Rebbe Yanna told Rebbe Samlai let’s go he really doesn’t want to learn he’s just giving me a hard time. But the Chavas Yair says that a rebbe is allowed to speak harshly to a student in order to motivate him to learn deeper and more diligently which was Rebbe Yannai’s intent in this case therefore it was permissible what he did. Obviously Rebbe Yannai was able to deduce that Rebbe Yehuda Hanasi was able to handle and learn from such rebuke.