We consider the almost sure asymptotic behavior of the periodogram of stationary and ergodic sequences. Under mild conditions we establish that the limsup of the periodogram properly normalized identifies almost surely the spectral density function associated with the stationary process. Results for a specified frequency are also given. Our results also lead to the law of the iterated logarithm for the real and imaginary part of the discrete Fourier transform. The proofs rely on martingale approximations combined with results from harmonic analysis and technics from ergodic theory. Several applications to linear processes and their functionals, iterated random functions, mixing structures and Markov chains are also presented.