I have a 6 foot piece of 8 x 8 hardwood barn beam that I'm intending to use as a mantel.The beam weighs about 130 lbs. My plan is to mount it on four half inch x 10 inch long lag bolts, each screwed five inches into a stud, with the remaining five inches going into the back of the beam. Is this safe, and/or is there a better way to do it?
Assuming the math checks out (ie, you have 2x6 studs), this should work. If you only have 2x4s, I'd think about getting more lags into the equation.
If it was my project, I'd use longer lags to have more resistance to rotation in the mantel. (12" lags give about 6" in the mantel, though you'd lose a little in the drywall and the removal of the lag's head.)
There's two hard things to this plan: the first is making sure you hit the absolute center of the studs. I'd cut drywall away to make sure I'm centered. (It'll be behind the wood, so any patching can be pretty basic.) Second is getting your lags drilled absolutely perfectly dead perpendicular, both to the mantel and the wall. The best case is using a drill press for the mantel, though that might be tough. Using a spotter and a speed square can be very helpful. Obviously, your holes need to line up perfectly as well.
To prevent the mantel from slipping off in the future, all you'd really need is a couple of long toe screws through the mantle into the studs. They aren't doing much work, so that doesn't need to be overdone.
If all this sounds daunting, you might explore other options, like a french cleat (metal, not wood) that would be more forgiving in terms of install complexity.