Ibrahim Liman, from the Civilian Joint Task Force (CJTF), said on Thursday that the attack took place on Tuesday in Ajeri village, which is located east of Maiduguri, the capital of Borno state.
"They came across nine Boko Haram gunmen in twos on three motorcycles who opened fire, killing five of the loggers," Liman said.
A second CJTF leader, Babakura Kolo, said that troops were attracted by the sound of gunfire, but the attackers fled before soldiers arrived on the scene. "The soldiers evacuated the five dead and the injured back to Dikwa along with 18 others who survived the attack."
News of the attack was slow to emerge, as nearly nine years of Boko Haram’s insurgency has destroyed telecoms infrastructure in the remote region.
Loggers have been increasingly targeted in Borno state over the past years. Boko Haram suspects them of passing information to the military and the CJTF, which assists troops with security.
This is one of the latest attacks against civilians in the violence-hit region.
On Wednesday evening, two female bombers detonated their explosives in Mandarari village, near the Borno town of Konduga, 36 kilometers southeast of Maiduguri.
The explosion happened shortly after another bomber killed four and injured over 40 at a displaced persons' camp in Dalori, 22 kilometers away on the same road to Maiduguri.
A fourth bomber also detonated her explosives outside the camp.
Ahmed Satomi, the head of the Borno state emergency management agency, said both attacks were "clearly the work of Boko Haram."
"They are trying to hit back as a result of the pressure the military has exerted on them in the current military operations against them in Sambisa forest,” he said.
In late 2016, Nigeria's military announced that it had cleared the militants’ Sambisa Forest stronghold, but they are said to have since returned.
According to reports, Boko Haram killed at least 967 people in 150 attacks in Nigeria, Cameroon, Chad and Niger in 2017, up on 2016 when 910 deaths were reported in 127 attacks.
More than 20,000 people have been killed since Boko Haram started its deadly campaign in northeastern Nigeria in 2009. The violence has claimed many lives in the neighboring countries.