In general, an integral has three parts: a polynomial part, a rational part, and a logarithmic part. Depending on the integral, some of these parts may be zero (and hence omitted).
Taking rational functions as our example, consider:
$$\int \frac{x^3}{(x+2)^2} dx = \frac{1}{2} x^2 - 4 x + \frac{8}{x+2} + 12 \log (x+2) + C$$
The logarithmic part is $12 \log (x+2)$, the rational part is $\frac{8}{x+2}$, and the polynomial part is $\frac{1}{2} x^2 - 4x + C$.
In the specific case of rational functions:
- The polynomial part is nonzero if and only if the degree of the numerator is greater than or equal to the degree of the denominator. You can find it by doing the polynomial division. The quotient corresponds to the polynomial part and the remainder corresponds to the rest.
- The rational part is nonzero if and only if the denominator is not squarefree. You can determine if a polynomial $p(x)$ is squarefree by calculating $\gcd(p(x), p'(x))$. How to actually calculate this is beyond the scope of this answer; ask your favourite search engine about the Hermite reduction as one example.
- Anything left over is the logarithmic part, and it can be found by partial fraction expansion on the squarefree part of the denominator. (The Rothstein-Trager method is another option.)
Interestingly, it's not just rational functions that this applies to; integrals over fields which involve more interesting functions can be understood along the same lines, except that there's often a "nonelementary" part left over, where the nonelementary part is typically a standard integral or a simple function for which no elementary integral exists. For example, for some constants $\alpha_{p}$, $\alpha_{r}$, $\alpha_{l}$, $A$ and $B$:
$$\int \frac{\tan^4 x}{(\tan x + 2)^2} dx = \alpha_{p} \tan x + \alpha_{r} \frac{\tan x}{\tan x + 2} + \alpha_{l} \log (\tan x + 2) + \int A \tan x + B\,dx$$
(Don't believe me? Take the derivative of both sides and see for yourself. Use the fact that $\frac{d}{dx}\tan x = 1 + \tan^2 x$.)
If you understand this as a polynomial in $\tan x$ (as opposed to $x$ in the first example), there's a clear "polynomial part", "rational part", "logarithmic part" and "nonelementary part" here.