EASTON – Both Democratic candidates for attorney general declared their opposition Thursday to a provision of the new domestic violence law that shields the identities of alleged offenders.

The law has been lauded for protecting victims and preventing abuse. It makes pepper spray purchases easier, provides paid employment leave for victims, delays bail for defendants and makes it harder for victims to drop charges, among other measures.

But the law, which took effect this month, also prohibits police departments from releasing reports or daily logs with any information about arrests or incidents related to domestic violence.

Supporters of the provision say it prevents the public shaming of victims, while critics say it shields the identities of those accused of domestic violence.

On Thursday, both Maura Healey and Warren Tolman came down on the side of the critics, arguing that the provision is an unfortunate aspect of an important piece of legislation.

“I don’t like that provision, quite frankly,” Tolman said.

Tolman, a lawyer and former state legislator, was speaking during a candidates forum at the Joseph Martin Institute for Law & Society at Stonehill College on Thursday evening.

The event also featured candidates for state treasurer and was sponsored by GateHouse Media, MassPoliticalNews.com, WCVB (Channel 5) and WGBH.

Healey, who Tolman faces in the Sept. 9 primary election, said she reviewed the domestic violence bill while working in the attorney general’s office. When it came through, she said, it did not contain the privacy provision, which she said “does not send a good message” of deterrence.

“I was surprised by it,” Healey said. “That provision troubles me.”

The candidates’ comments stand in contrast to a less forceful statement from Attorney General Martha Coakley’s office after the bill was signed into law.

That aspect of the domestic violence law was not the only issue Tolman and Healey largely agreed on Thursday night. They both said more needs to be done to combat the opiate epidemic, sexual assault on college campuses and corruption.

The candidates disagreed most clearly on casinos.

Tolman supports the casino gambling law passed in 2011 and said Thursday he will vote against its repeal in November. Healey has been a vocal opponent of casinos.

The winner of the Democratic primary will face Republican John Miller, a lawyer from Winchester, in the general election on Nov. 4.