Take the example:
Integrate the following: $\frac{\ln (x)}{x} dx$
The correct way I've found is to substitute $u$ for $\ln (x)$ and $\frac{1}{ x} dx$ with $du$, therefore:
$\frac{u^2}{ 2}$ or $\frac{(\ln x)^2}{ 2}$ is the answer.
However, if I try to substitute $x$ with $u$ I can't solve it correctly.
What is a general rule to determine which part of the equation to substitute for $u$ when integrating?
By practice, practice and more practice you get experience and thus you shall be able to recognize patterns. Observe that
$$\frac{\log x}x=\frac1x\cdot\log x=\frac{d}{dx}(\log x)\cdot\log x$$
and now remember that
$$\int f'(x)\cdot f(x)^n\,dx=\frac{f(x)^{n+1}}{n+1}+C$$
so in our case we can see we have an (almost) immediate integral:
$$\int\frac{\log x}xdx=\int(\log x)'\cdot\log x\,dx=\frac{\log^2x}2+C$$
If I can avoid substitutions then I do. This will pay off both in speed and when working with Riemann Integrals, as then we won't have to calculate the new upper and lower limits of the integral.