Yellow "bug lights" are used to avoid attracting swarms of insects, especially moths, to outdoor lights at night. Moths and other nocturnal insects are not very sensitive to yellow wavelengths of light, but extremely sensitive to white light and ultraviolet.
Some yellow bug lights are more effective than others, and the photograph below shows a moth attracted to an unusually bug-attracting yellow light bulb in a yellow glass shade. The camera makes the light bulb look white, and perhaps this is how the moth also sees it.
Moths are not so much attracted to artificial lights as they are confused by them. Most moths are nocturnal and only emerge after dark, thus they should be repelled by bright light instead of attracted to it. Bright artificial lights may confuse a moth's navigation system or impair it's visual perception. Moths are used to navigating by relatively dim moonlight or starlight, and the presence of a much brighter and closer light source may be overwhelming, especially since the moths can actually touch the brilliant light source and even fly above or around it, unlike with the sun, moon, or stars.
The frantic, erratic, circling, and fatally reckless behavior that moths exhibit around artificial lights looks more like the confusion and light-madness it is than the simple attraction it was once thought to be. Moths don't exhibit similar confusion in sunlight, instead they just quickly fly off to the first, dark, shaded place they can find and wait there for nightfall.