# Convergence of a sum over primes

I am trying to understand a condition for a nonincreasing sequence to converge when summed over its prime indices. The claim is that, given $a_n$ a nonincreasing sequence of positive numbers,
then $\sum_{p}a_p$ converges if and only if $\sum_{n=2}^{\infty}\frac{a_n}{\log(n)}$ converges.

I have tried various methods to prove this but my error estimates are always too large.
The closest I came to a proof is this: first, extend the sequence $a_n = a(n)$ to positive reals by "connecting the dots" (interpolating by some nondecreasing function that takes on the same values as $a_n$ on the integers. Then, do the same for $\pi(x)$ (prime counting function) and $p(x)$ (the n-th prime). The goal is to use the integral test to relate the two sums.

So $\sum_{p}a_p$ converges if and only if $\int_{1}^{\infty}a(p(x))dx$ converges.
Using the substitution $t = p(x)$ (so $x = \pi(t), dx = \pi'(t)dt$), the second integral equals $\int_{2}^{\infty}a(t)\pi'(t)dt$. By the Prime Number Theorem, $\pi(t) = \frac{t}{\log(t)} + O\left(\frac{t}{\log^2(t)}\right)$, so the derivative is (intuitively) $\pi'(t) = \frac{1}{\log(t)} + O\left(\frac{1}{\log^2(t)}\right)$. So, assuming this "intuition" is correct, the integral is $\int_{2}^{\infty}\frac{a(t)}{\log(t)}dt + ...$ where the ellipsis are terms of lower order than the main term. This integral converges if and only if $\sum_{n=2}^{\infty}\frac{a_n}{\log(n)}$ converges.

That would be good, but I am unable to prove the "intuitive" step. I need some estimate on the order of the derivative of $\pi(x)$, but the only information I have is the big-Oh of the function, not its derivative.