Whenever we write something like $\ln(x)$, we are implicitly asserting that $x$ is restricted to those $x$s for which the expression makes sense.
When we write $\frac{d}{dx}\ln(x) = \frac{1}{x}$ we are then implicitly and automatically saying that $x$ is positive for the equation to make sense. As for integrals, that's why $\int\frac{1}{x}\,dx = \ln|x|+C,$ with the absolute values: note that \frac{d}{dx}\ln(-x) = \frac{1}{-x}(-x)' = \frac{1}{x} as well by the Chain Rule, so that $\frac{d}{dx}\ln|x| = \frac{1}{x}.$
For a definite integral to make sense, you usually need the function defined on the entire interval of integration (at least, for the usual Riemann integrals), so $\int_a^b\frac{1}{x}\,dx$ cannot have $a\lt 0 \lt b$ and make sense. Either $0\lt a\lt b$ or $a\lt b\lt 0$.
You can try to do an integral $\int_a^b \frac{1}{x}\,dx$ with $a\lt 0\lt b$ as an improper integral, but you will find that the integral does not converge; neither do $\int_0^b\frac{1}{x}\,dx$ nor $\int_a^0\frac{1}{x}\,dx$.