Updated

The superintendent of the U.S. Air Force Academy delivered a stern message to cadets Thursday, warning them that racism would not be tolerated after slurs were written on the doors of five African-American students at the academy's prep school earlier this week.

At one point in his remarks, Lt. Gen. Jay Silveria insisted that everyone in the audience take out their phones and record him so his message was clearly heard.

"If you can't treat someone with dignity and respect, get out," said Silveria, a 1985 graduate of the academy.

A Pentagon official told Fox News the slurs were discovered Monday. The Air Force is investigating. Racial slurs are illegal in the military and can bring charges of violating orders and conduct unbecoming an officer.

Silveria said he called the families of the five prep school students who were the objects of the slurs.

His speech quickly became a widely viewed video online, coming in the aftermath of racial violence in Charlottesville, Va., and the debate about NFL players kneeling for the national anthem.

"We would also be tone deaf not to think about the backdrop of what is going on in our country. Things like Charlottesville, Ferguson, the protests in the NFL," he said.

Silveria, a veteran fighter pilot who directed the air war in the Middle East, took command at the school in August. The academy has struggled with sexual misconduct problems several times in recent years, and Silveria has repeatedly told cadets and staff that his highest priority is ensuring a climate of dignity and respect. Silveria enrolled at the academy a year after it graduated its first female cadets.

When he took over as the school's leader, he told The Gazette: "My red line is cadets who can't treat each other with respect and dignity."

About 29 percent of the academy's cadets were minorities in 2015, according to the school's website. Ten percent were Hispanic, 10 percent Asian and Pacific islander, 8 percent black and 1 percent Native American.

The U.S. Air Force Academy Prep School is located on the same campus as the Air Force Academy in Colorado Springs, Colo. The prep school is a one-year program for about 240 potential cadets who applied for the four-year academic and military program at the academy but were not accepted. The goal is to help them meet academy requirements.

The Associated Press contributed to this report.