Generally there are two ways to power our lights: generator or batteries. Battery lights are usually removable, so we don't have to haul them around in daylight. They don't slow you down, they shine regardless of your speed and can be used as a handheld torch if needed. On the other hand, batteries can die, and an easily removable light can be easily removed by a thief too.
Most of today's battery lights use LEDs, so the only possible failure (besides drained batteries) is a bad contact. Usually it can be solved by disassembly and cleaning, sometimes by solder. Watch out for water - if your lights are not rainproof and you get hit by a downpour, you may unexpectedly turn into a Dark Knight.
A device commonly known as a dynamo (which is actually alternator) provides unlimited power and it's hard to steal. On the other hand, it slows you down a little and it wouldn't look very cool on racing or mountain bikes. The usual power output of a dynamo is 3 W and 6 V at cca 20 km/h and a load of two light bulbs. There are also 2.4 W types designed to power the headlight only.
Almost all older bikes and some cheaper new ones use tyre-driven "bottle" dynamo and two classic light bulbs. This system is very simple: resistance of a light bulb grows with the filament temperature, so the current is self-regulated and there is no need for electronic stabilizers. There are two disadvantages: poor efficiency of the bulbs (roughly in the order of single percents) and mediocre reliability (bulbs get blown sometimes, although this has never happened to me in several years of evening commutes; slippage of the generator is more frequent, especially in snow).
The most frequent problem of dynamos are bad contacts. Most often the spring-loaded metal bit which holds the power cable oxidizes, because it's close to the wheel and catches a lot of dirt. Solution: clean the hole with a round needle file. If it doesn't help, try to look inside and clean the contacts in there as well. If this didn't help, there's a method that's guaranteed to work: solder two cables directly to wires coming from the stator coil, connect first one to the bike frame outside and fork the other one to the lights:
Other weak spots are all other contacts everywhere else. It's good to apply solder to the ends of all cables and ideally solder them in place (but that makes disassembly difficult). Also look out for the second pole which is routed through the frame. Light fixtures and brackets are electrically connected by sharp screws penetrating the paint. This exposes some bare metal to the elements and when it gets rusty, it loses conductivity.
Another problem is whirring and whistling of a dynamo that occurs in a narrow range of speeds. It is caused by increased clearance and insufficient lubrication of the rotor bushing. A solution is to disassemble the dynamo, clear the bearing and grease it properly (by some not very thick grease). Old aluminium dynamos made in East Germany (can still be seen on some European bikes) can't be disassembled, so you can only drip oil inside, and discard them when it stops to help.
The pictured silver dynamo once failed in a funny way. Its bushings are plastic rather than bronze. Old grease dried out, the shaft seized and the whole bushings started to spin within the housing. The plastic parts melted nicely, but fortunately all important parts survived. Fixed by cleaning, greasing, and epoxying remains of the bushings in place. And by purchasing a spare dynamo :-).
The most reliable dynamos are those integrated in wheel hubs. Rolling resistance is unnoticeably small, they work regardless of weather and have almost nothing to break down.
If you want to replace incandescent bulbs with LEDs, you need to know volt-amper characteristics of your power source and fit the circuit to them. LEDs don't have the self-regulating ability of classic bulbs and overcurrents can destroy them. On the other hand, a well-designed LED circuit can work practically forever. You can find characteristics of some generators in the Reviews section.