This paper is concerned with the performance of energy detection for spectrum sensing in cognitive radio. Both fading and shadowing are considered by assuming a Nakagamilognormal composite channel model. Based on a newly-derived exponential integral representation for the generalized Marcum Q-function, performance analysis of energy detection is formulated as a unified moment generating function (MGF) approach. Energy detection without diversity is addressed first. The proposed MGF approach is then extended to the case of energy detection employing square-law combining (SLC) and squarelaw selection (SLS). With the help of an accurate approximation to the MGF of the Nakagami-lognormal composite channel, the effects of fading and shadowing on the performance of energy detection are investigated numerically.