How long a break?
Most health and safety guidelines suggest that you should be taking a 5-10 minute break every hour anyway if you're working at a computer. In practice the only person I've worked with who ever made an active effort to ensure that, was an RSI sufferer. But what with toilet breaks, fetching drinks, chatting to colleagues, and so on, it's not difficult to be there or thereabouts: it's only 7 breaks in an 8 hour coding day, and one of those merges into lunch. Add 3 trips for coffee/jolt/water/JD, plus a 10 minute argument about whether the Cowboys are for real, and you maybe manufacture the other two by walking round the building for no reason.
If you can sit and write code for 3 hours straight, take a lunch break and then do it again, then you're already through almost all of a regular working day. And in practice it's only the good days you even get the chance to do this, what with email, meetings, phone calls, code consultations, etc.
On the other hand, if 3 hours coding is your limit for the day, then you'd be in trouble. Except during crunch times (and some shops are better at avoiding crunches than others), you generally don't have to be able to code/debug for 8-10 hours solid every day in a programming job. But 3 hours "real work" per day is below expected productivity.
The biggest thing I do to avoid mental fatigue and boredom is to think about something different. Aside from your main programming task, have something else on the go at the same time: a bit of design you'll need tomorrow, or a code review someone's asked you to do, or a bug report you haven't assessed yet, or something non-code-related that needs doing. Then you can "take a break" without actually stopping work. Again, in practice in a real workplace it's not usually difficult to find secondary tasks - usually if there's a problem then it's too many simultaneous tasks.
I particularly like code consultations - I'm most happy in an office where it's acceptable to wander up to random people, and (assuming they aren't too busy) discuss any ideas you're working on and want a second opinion. Equally I like other people to be telling me what they're doing - I guess I'm just nosy. It gives people a chance to think about things other than their current main task, pool their experience and knowledge, and learn about bits of the product they aren't directly working on. Of course it can go too far - you don't want to interrupt someone who's "in the zone" on their own work, with a question about how to optimise quicksort. But it's something you really don't get working alone and as a hobbyist, and it really does help avoid getting tired of what you're doing.