Just to expand on Hritik's great answer with a little more physical insight:
Energy as a "stuff", friction in this picture.
Very often we can define a scalar field (a smoothly-varying set of numbers, one for each point of the space) which describes everything about a pattern of forces. We call this the "potential energy" field. It is useful because a quantity called the total energy is conserved, this includes the kinetic and potential energies of all of the particles in a system.
Now we have to talk about friction: it is the big situation where energy is not conserved. But this is really easy to understand too, because friction leads to heat-energy, and heat-energy is known to just be kinetic-energy for things that we don't care about.
Example visualization of the world in terms of energies
So if you think about dropping a bouncy ball from the top of a building, it's the same as if you have 2 cups of some liquid "stuff" (total energy) in some basin (energy of all the things you don't care about). Your cup labeled "kinetic energy of ball" has little holes drilled through the sides (air drag). Your potential energy cup is bigger, and is full. Nature pours energy from the potential into the kinetic cup at first, with droplets running out of the sides as the holes leak out some energy to air drag. Then the liquid level might come to some stable level (terminal velocity) where the liquid poured in is the same as the liquid going out through those holes. Finally the ball hits the ground, which basically shakes this kinetic energy cup, sending a spray of liquid into the basin, before Nature starts pouring the kinetic energy back into the potential energy cup. When it's empty (particle is at its maximum), Nature starts pouring the potential energy back in all over again.
The process continues until both cups are empty -- or, more precisely, when they have both come to the same level as the energy level in the basin (thermalization), which may not be 0. (Consider air molecules when they hit the ground: hopefully the Earth thermally-bounces them back with enough oomph to get up to the upper atmosphere, otherwise our whole atmosphere is about to collapse!)
Minimizing potential energy, flotation
Now we can use this as a general rule for where things eventually trend: a system eventually finds itself thermally jittering around a minimum of potential energy. If we neglect the thermal jitter for big systems, we have that Nature just in general directs things to minimize their potential energy. Call this the "minimum energy principle," the universe "wants" things to be at their lowest (potential) energy state, in the sense that energy will often gradually leak out into the surrounding world until this happens.
(Notice that it also depends on the sort of friction: "static" friction overcomes this tendency for short timescales, which is why you can park a car on a hill. Basically, in this picture of the universe, static friction creates small potential energy wells whenever two surfaces of sliding solids are at rest relative to each other, as atoms between these two "bond".)
We can use this to figure out when something floats: just ask what the total energies are. Let's keep the object completely submerged so that we don't have to ask difficult questions about how the water level lowers as it comes out of the water and so forth.
You have an object, like a box of stuff, with some volume $V$ and density $\rho_o$ which can either be at the bottom of the liquid $(h=0)$ or the top of the liquid $(h=H)$, and the liquid has density $\rho_\ell.$ We know that there will be all sorts of complicated drag forces but the system will eventually minimize the total potential energy, and all of the other energy will be heat in the liquid and currents of liquid and the like.
Now calculate the total potential energy when it is at the top: $\rho_o V g H.$ Easy peasy. (Add a constant term $L$ for the potential energy of all of the liquid.) Now what happens when it's at the bottom? 0? No.
Well, it's a little complicated: there is no place for the object at $h=0$ just yet, it's all full of liquid. When the object is down there, it displaces that same volume $V$ of liquid, moving it out of the space it occupies. That liquid ultimately displaces other liquid and so on until the "hole" at the top of the box is filled! We can actually abstract all of this away by imagining that we freeze time and just cut a box-sized hole of volume $V$ in the liquid at height $h=0$ and take that "box of liquid" and swap it with the object. The energy is therefore $\rho_\ell V g H$ as that box of liquid was moved to the top. Comparing this with the earlier expression we can see that $V$, $g$ and $H$ are the same. Our minimum-energy principle says therefore that things float when $\rho_o < \rho_\ell,$ and sink when $\rho_o > \rho_\ell.$
Furthermore, we discover that if something naturally has a density less than the liquid, so that it wants to float, a total energy $(\rho_\ell - \rho_o) V g h$ will be liberated by allowing it to float upwards be a height $h$.
(We can also now understand why logs prefer to float lengthwise -- water wants to be lower more than the log does so the log tries to concentrate its mass up at the surface of the water. And we can understand the more general case of stuff floating "out of" water: the only thing that the water notices is the "submerged volume" $V_s$ below the water line, which as far as the water is concerned bears the whole mass $m$ of the ship/log/whatever. So it has an effective density $\rho_e = m / V_s$ -- but since it's neither floating nor sinking, $\rho_e = \rho_\ell$ and we can therefore calculate $V_s = m / \rho_\ell$ to figure out how much volume gets submerged.)
How this applies to your case
When you shove the log into the water, you must therefore also displace the water, essentially pushing a "box" of water from the bottom to the top of the water column. This costs you an up-front energy $\rho_\ell~V~g~H$ just to shove the log into the water.
Now suppose that you tied the log to some very thin but strong fishing line, which goes out the bottom of the rig: it pulls a flywheel via some gearing mechanism. So every tiny bit of energy that this system gets by floating upwards is now going to be harvested into this flywheel. (Maybe we then want to use that energy to shove other logs into the water column?)
Well, we find that we spent an energy $\rho_\ell~V~g~H$ but in ideal circumstances we recover an energy $(\rho_\ell - \rho_o)~V~g~h,$ leaving us with the net deficit $-\rho_o~V~g~H$ which we have to supply from some external means. But... that's just the energy that you'd need to supply via any mechanism to lift that log.
A similar situation happens, for example, if you try to slurp up a volume $V$ of liquid at the bottom as the log goes in (zero cost to get in, yay!) and then let it float to the top. You get lifting for free, hooray! Except... now you've lost a volume $V$ from your reservoir, and if you ever want to put it back in, you're going to have to pay that cost to lift a volume $V$ of water back to height $H.$ You just used the water column itself as a "waterfall" of sorts to power the lifting of the log.