Sheffield Crown Court heard how the fire service were called out to the blaze started by John Bortoft, 32, in a bathroom at the Sanctuary supported accommodation he was staying at, after a fellow resident heard the alarm sound.
"She went out and investigated and soon became aware there was smoke and a fire," Alisha Kaye, prosecuting, told the court.
Ms Kaye added: "She went downstairs and called the fire service, and describes the defendant repeatedly shouting: 'It wasn't me'.
"He then started spraying the fire extinguisher in random directions and laughing."
Water damage to the property caused by the fire spreading to under-floor piping eventually helped to put the blaze out, the court heard.
"The fire service determined the fire was started intentionally, and was caused by toilet paper being set alight," added Ms Kaye.
No-one was injured in the blaze, but approximately £3,000 was caused to the property.
The court was told how Borfoft has an 'atrocious' criminal record some 28 pages long and includes a previous conviction for arson.
Bortoft, 32, pleaded guilty to one count of arson so reckless as to endanger life at an earlier hearing.
Karen Tuncliffe, defending, said: "He regrets what he has done and shows remorse. He has done what he can to try and help himself, since being remanded into custody.
"He is now liasing with the mental health team and is trying to detox."
Judge Peter Kelson QC sentenced Bortfoft, of no fixed abode, to three years in prison.
He told him: "You are a dangerous man. I am conscious of all of your vulnerabilities and problems, but I must also be conscious of those around you and the risk from you."