Surveillance images allegedly show Gavin Long dressed in black and carrying a semiautomatic rifle. (Louisiana State Police)

The man who shot and killed three police officers in Baton Rouge last summer had searched for the addresses and phone numbers of two other officers involved in the killing of Alton Sterling, whose videotaped shooting sparked unrest in the city, according to an investigative report released Friday.

Gavin Long, 29, of Kansas City, Mo., never used the biographical information he gathered on the officers involved in Sterling’s killing to attack them, though he did target police in his shooting rampage, according to the report. The report said investigators found evidence of the searches on Long’s laptop.

In a suicide note, Long wrote that he saw his actions as a “necessary evil” intended to “create substantial change within America’s police force.”

“Therefore I must bring the same destruction that bad cops continue to inflict upon my people, upon bad cops as well as good cops in hopes that the good cops (which are the majority) will be able to stand together to enact justice and punishment against the bad cops b/c right now the police force and current judicial system is not doing so,” Long wrote.

Long’s suicide note and the investigative report about the incident were released Friday by East Baton Rouge Parish District Attorney Hillar Moore III, whose office had been investigating the shooting. Moore concluded that officers were justified in shooting and killing Long amid a rampage in which Long killed three of their own: Baton Rouge Police Officer Montrell Jackson, 32; Baton Rouge Police Officer Matthew Gerald, 41; and East Baton Rouge Sheriff’s Deputy Brad Garafola, 45.

The report offers one of the most detailed accounts to date of the June 17, 2016, incident — though Long’s actions and possible motives had been public for some time. Long had an expansive presence online indicating that he was eager for black people to take a strong physical stance against mistreatment by authorities.

His attack came at a time of significant tension between law enforcement and minorities. Less than two weeks before the shooting he perpetrated, another attacker had shot and killed five police officers in Dallas. Long seemed to praise that incident in an online video.

“I’m not gonna harp on that, you know, with a brother killing the police. You get what I’m saying?” Long said, according to a video posted online. “That’s, it’s justice.”

Long, who had spent five years in the Marine Corps, ultimately targeted Baton Rouge officers and deputies who he encountered by chance, though his searches of the particular officers involved in Sterling’s death perhaps indicates why he chose the city he did.

The two officers — Blane Salamoni and Howie Lake — were caught on video scuffling with Sterling, 37, when he was shot. The incident, which occurred less than two weeks before Long perpetrated his mass shooting, prompted protests in Baton Rouge, as many felt the killing was unjustified.

A little less than two months ago, the U.S. attorney in Baton Rouge announced that neither officer would face federal charges, as investigators were not able to determine whether Sterling was reaching for a gun when an officer yelled that he was.

Investigators also found in Long’s vehicle a printout from an Islamic holy book — which the district attorney said was particularly noteworthy evidence because it indicated “a premeditated attack on law enforcement that Long did not plan to survive.”

The document included a prayer passage that said repeating the prayer and dying on the same day would guarantee that the person goes to paradise, according to the report. An autopsy determined that Long had methamphetamines and alcohol in his system when he died.