A common version of summation by part formula is $$ \sum_{n\le x}a(n)f(n)=A(x)f(x)-\int_1^xA(t)f'(t)\,dt $$ where $A(x)=\sum_{n\le x}a(n)$.
To get a formula for $\sum_{n\le x} b(n)$, we often need to write $b(n)=a(n)f(n)$ for some $a$ and $f$. The choice of $a$ and $f$ may not be unqiue. My question is: is there a general principle to select $a$ and $f$? For example, when $b(n)=\frac{\log n}{n}$, shall we set $a(n)=\log n$ and $f(n)=\frac{1}{n}$ or the other way around $a(n)=\frac{1}{n}$ and $f(n)=\log n$? I did the calculation in this case and it seems to me that both choices gave the same main term and error term. I guess in some other examples, one choice of $a$ and $f$ will lead better error term than the other choices.
Euler's summation formula, or more generally Abel's summation formula is often applied in analytic number theory. Then number-theoretical considerations immediately suggest how to choose $a(n)$ and $f(t)$. A nice example is the proof of Dirichlet's theorem on arithmetic progressions. It uses Abel's formula (and something more) to obtain $$ \sum_{p\le x,p\equiv h(k)}\frac{\log(p)}{p}=\frac{1}{\phi(k)}\log(x)+O(1), $$ see Tom Apostol's book on Analytic Number Theory.