What has a log, ie piece of wood, got to do with a log on board ship? Originally a piece of wood was used to determine the speed a ship was going at. It wasn't a chunky log exactly, but a thin piece of wood that was designed to float upright. It was attached to a line wound around a reel. The piece of wood was thrown overboard and as the boat moved through the water the line would unwind. Depending on how quickly the string or rope unwound, the speed could be estimated.
At first the log-line was not knotted, but in around the 16th century when the standard measure at sea, the nautical mile, began to be used, sailors would knot the line at regular intervals and count how many were on the length of rope that had unwound. This is the origin of the word knots, a measure of distance or speed at sea.
When the captain filled in his book with details of the ship's voyage, one of the most important details to record was the speed and distance covered. Since it was the log, or piece of wood, that had provided this information, the book itself came to be termed a log, too.