# Sum of log p/p for p equivalent to l mod D

It's fairly classical that for $D>1$ and $(D,l)=1$ one has $$\sum_{\stackrel{p\leq x}{p\equiv l\; (mod \; D)}}\frac{\log p}{p} = \frac{\log x}{\phi(D)} + \textrm{O}(1)$$ where if I understand correctly the dependence on $D$ in the $\textrm{O(1)}$ is captured by something like $$\frac{1}{\phi(D)}\sum_{\textrm{non-principal} \; \chi}\frac{-L'(1,\chi)}{L(1,\chi)}$$ which is $\ll_{\epsilon}D^{\epsilon}$ for any $\epsilon>0$. If this is correct, suppose I am interested in the sum $$\sum_{\stackrel{p\leq x}{\left(\frac{-D}{p}\right)=1}}\frac{\log p}{p}$$ where $\left(\frac{-D}{p}\right)$ is the Legendre symbol. There are $\phi(D)/2$ residue classes mod $D$ that $p$ can lie in, and so then this is just my previous sum $\phi(D)/2$ times, and I get that it's $1/2 \log x +\textrm{O}(1)$, where the dependence on $D$ in $\textrm{O}(1)$ is now something like $\textrm{O}(D^{1+\epsilon})$. Is this the best one can do? I was hoping I could get it to be $\textrm{O}(D^{\epsilon})$ but if that's not even correct perhaps I should stop trying.

-

Somewhat more precisely: the Legendre symbol $\big( \frac{-D}p \big)$, or rather its multiplicative generalization the Jacobi symbol $\big( \frac{-D}n \big)$, is a Dirichlet character (mod $D$)—call it $\chi_1(n)$. The sum you are interested in is just $$\sum_{p\le x} \frac{\log p}p \bigg( \frac{1+\chi_1(p)}2 \bigg).$$ (Not exactly, since this expression counts primes dividing $D$ with weight $1/2$, but that's easily dealt with.) Therefore you're left with needing to understand $\sum_{p\le x} (\log p)/p$ (no problem) and $\sum_{p\le x} (\chi_1(p)\log p)/p$. The latter sum is going to be $O(1)$ in the same way that the error term in the classical problem is $O(1)$; it is going to be related to $-L'(1,\chi_1)/L(1,\chi_1)$. So in fact you don't have all the different $-L'(1,\chi)/L(1,\chi)$ error terms to deal with, only the single one where $\chi=\chi_1$.
That's a good question, as it illustrates that one should try to find the "correct" harmonic analysis for a given problem (of this type...). What you can do is represent the characteristic function of your set of interest (the $p$ where $(-D/p)=1$) as a combination of Dirichlet characters; by quadratic reciprocity, you only need the principal character and a real character. So you can get your error term as the sum of two error terms coming from $$\sum_{p\leq x}{\chi(p)\log(p)/p}=\delta(\chi)\log(x)+(Error).$$ This should give what you want.