Hot objects can glow — this is called “black body” radiation. Glowing embers and the sun fit into this category.
Certain chemical reactions produce light. Fire and glow sticks fit into this category.
Charged particles that change direction or speed of travel can give off electromagnetic radiation, including visible light. The Synchrotron and radio/TV transmitters and microwave ovens fit into this category.
Atoms and molecules can have certain special “allowed” energies. When atoms and molecules change from a higher energy state to a lower energy state, that change releases the energy difference between the two states. If this seems complicated, don’t worry, you study it in year 11 or 12 physics and chemistry. Fluorescent lights and lasers fit into this category.
There are probably one or two other ways of producing light, but as a non-physicist, I don’t remember them.
Ah – well light is being emitted by really bright and reactive species that are being formed. Fire produces a lot of very odd molecules and part-molecules and reactive things called radicals. These come off the log and rise and they are reacting the whole time and cooling. In the process of relaxing they will give off some of their excess energy, and we see some of that as light. By the time they get to a few centimeters above the log they’re done with that and have finished giving off most of the energy, so the flame stops.