We study the compact embedding from W 1,2 0 (Ω) to L q(x) (Ω) with a variable critical exponent 1 q(x) 2N/(N − 2), N 3 if there exist a point x 0 ∈ Ω, a small η > 0, 0 < l < 1 and C 0 > 0 such that q(x 0 ) = 2N/(N − 2) and q(x) 2N/(N − 2) − C 0 / (log(1/|x − x 0 |)) l for |x − x 0 | η. As an application, we show an existence of a positive solution to the nonlinear elliptic boundary value problem − u = u q(x)−1 in Ω, u(x) = 0 on ∂Ω.