I'd like to weigh in on this question with some more info, because the question of how the technique works does not seem to be fully answered to me.
A substitution is actually shown in full in episode 403: Unwavering Gutsiness at around 16 minutes in. Unfortunately, it's not a log substitution, but an insect one. Still, I imagine it's the same for a log. Kiba and his teammates all move away at high speed while the insects take their place and transform into insect clones. Thus, it is as the Naruto wiki states:
The instant before they are to be struck by an attack, the user replaces themselves with a block of wood or something similar. Because the attack does hit something, opponents may briefly believe that they've successfully struck the user. But this is merely an optical illusion and opponents will quickly notice what's happened.
Substitutions are probably also shown at other points in the series or explained. But from this scene, we can see that they aren't using teleportation or summoning jutsu to do the substitution, but rather that they simply move away at high speed and hide, while leaving something to take their place. Using smoke and other sleight-of-hand distractions are helpful in creating the illusion, and we see the smoke a lot in the log substitutions in Naruto.
As stated in SingerOfTheFall's answer, ninja substitution is indeed part of the real world myths of ninjas in Japan, and appears a good deal in their fictional works. Another description of the technique can be found in A Certain Scientific Railgun volume 14, by one of the ninja in the 4-Koma at the end:
"When you sense an incoming attack... You dress a log in your clothing... And it takes the attack for you! The art of substitution! So secret and difficult it's never been seen in battle!"
"That's... Probably because if you're that fast, you have way less complicated options, dummy!"
In fact, all three of the 4-Koma at the end are about logs and substitution, and they kind of lampoon the popularity and ridiculousness of the technique, like the second one where the ninja characters lament the suggestion of just using a 3-D hologram:
["If we had city tech..."]
"I wouldn't need to carry a log around all the time, for starters."
"Or a change of clothes for the log."
"Um, what about... a handy 3-D projector?"
"But... B-But the look on your opponent's face when they realize they've struck a log, of all things!"
"But the log...!"
"The log..."
"Will you forget about the log for a second?!"