The 26-year-old Swiss was beaten in the first round in Dubai by Briton Andy Murray this week, his first match since losing to Novak Djokovic in the semi-finals of the Australian Open in January.
Federer, who has spent a record 214 consecutive weeks at the top of the men's rankings, said he became severely ill on holiday in Switzerland after the Australian Open and was diagnosed with mononucleosis (glandular fever), a virus causing fevers, sore throat and swollen lymph glands.
The Swiss said he first began feeling ill at the end of last year and was unable to play before the first grand slam of the year in Melbourne. He has only played two tournaments so far in 2008.
"During the time in Melbourne I felt slow and kept looking for possible reasons for that - without finding an answer," Federer posted on his Website on Saturday.
"Some time later, during my holidays in Switzerland, I became severely ill again. I went to the hospital straight away to get further tests done. And it was at this time that they found out what was bothering me all along: mononucleosis.
"It was relieving to finally know why I had felt weak in Australia and also later on during my holidays. So the good news really is to be certain of what has occurred.
"The bad news is that I have quite some catching up to do in terms of fitness as I am not in the physical state that I would normally be in at this time of the year."
Federer, who is just two behind Pete Sampras's record grand slam haul of 14, says he is now training normally and is looking forward to playing the American in an exhibition match in New York on Monday.
He will then focus on the Indian Wells tournament. (Reuters)