It seems that $\displaystyle\int_0^{+\infty}\frac{\cos x}{x}$ is divergent, so how to solve this problem?
$$\int_0^\infty \frac{\cos bx -\cos ax}{x}\, dx\quad,\quad\mbox{where}\,a,b>0$$
It's really a great challenge for me.
If there's any advice of hint I would be grateful!
In general, if $f(x)$ is a continuous function over $(0, \infty)$ such that following two limits exist
$$\begin{cases} f_0 &= \lim\limits_{x\to 0} f(x),\\ f_\infty &= \lim\limits_{x\to\infty} f(x) \end{cases}$$ then $$\int_0^\infty \frac{f(bx) - f(ax)}{x} dx = (f_0 - f_\infty)\log\frac{a}{b}\tag{*1}$$
This is known as Frullani integral.
In your cases $f_0$ exists but $f_\infty$ doesn't. However, there is a generalization which only require the existence of following limit: $$f_\infty^{alt} = \lim_{L\to\infty}\frac1L\int_1^L f(t) dt$$
For $f(t) = \cos(t)$, $f_0 = 1, f_\infty^{alt} = 0$. $(*1)$ tells us
$$\int_0^\infty \frac{\cos(bx)-\cos(ax)}{x} dx = (1 - 0) \log\frac{a}{b} = \log\frac{a}{b}$$
For a proof of Frullani's theorem, look at answers in this question. In particular, this answer which cover the generalized version you need.