In this paper, we will give a certain formula for the Riemann zeta function that expresses the Riemann zeta function by an infinte series consisting of $K$-Bessel functions. Such an infinite series expression is regarded as an analogue of the Chowla-Selberg formula. Roughly speaking, the Chowla-Selberg formula is the formula that expresses the Epstein zeta-function by an infinite series consisting of $K$-Bessel functions. In addition, we also give certain analogues of the Chawla-Selberg formula for Dirichlet $L$-functions and $L$-functions attached to holomorphic cusp forms. Moreover, we introduce a two variable function which is analogous to the real analytic Eisenstein series and give a certain limit formula for this one. Such a limit formula is regarded as an analogue of Kronecker's limit formula.