There is a general (mis)conception that
$$\int \frac{1}{x} \, \mathrm{d}x = \ln|x| + C \label{1} \tag{1}$$
However, taking the indefinite integral as the set of all functions whose derivative is $\frac{1}{x}$, the technically correct answer should be
$$\int \frac{1}{x} \, \mathrm{d}x = \begin{cases} \ln(x) + C & \text{if $x > 0$} \\ \ln(-x) + D & \text{if $x < 0$} \end{cases} \label{2} \tag{2}$$
See Your calculus prof lied to you (probably) for more details.
Is $\eqref{2}$ correct and is $\eqref{1}$ incorrect? Or are they both acceptable?
I suppose $\eqref{2}$ is more correct but it perhaps doesn’t have any additional value compared to $\eqref{1}$ as the definite integral will give the same result for both (as the integral diverges if we move from the negative to positive $x$-axis).
Is there any other example where failing to define a piecewise function (with separate constants) as an integral can have serious consequences?


Whenever you see a formula in the form of $$ \int f(x)\;dx = F(x)+C\;\tag{*} $$ there is implicitly some open interval $I$ that is the subset of the "natural domain" of the function $f$. The formula is interpreted as all the solutions to the differential equation $$ F'(x)=f(x),\quad\quad x\in I\;.\tag{**} $$
In this context, the important property of open intervals is that they are connected, and that's why one has only one "arbitrary constant $C$".
In the case when $f(x)=\frac1x$, the natural domain $D=\mathbf{R}\setminus\{0\}$ is not connected. Then ($*$) is true for any given open interval $I\subset D$.
However, if one wishes to express the solution set to the differential equation $$ F'(x)=\frac1x,\quad x\in D=\mathbf{R}\setminus\{0\}\;, $$ one needs two arbitrary constants, basically because there are two connected components of the domain $D$. That is what you write in (2) of your post.
So when one has a piecewise-defined function $f:D\to\mathbf{R}$ where the domain $D$ is not connected and if one wants to use $\int f(x)\; dx$ to express the set of all the solutions to the differential equation $$ F'(x) = f(x)\quad x\in D\;, $$ then one needs more than one "arbitrary constant", depending on the number of connected components of $D$. For instance, let $D=(0,1)\cup (2,3)\cup(4,5)$ and define $f:D\to\mathbf{R}$ with $f(x)=0$ for every $x\in D$. Then the solution set to $$ F'(x)=f(x)\;,\quad x\in D $$ is $$ F(x)=\begin{cases} C_1\;,&x\in(0,1)\\ C_2\;,&x\in(2,3)\\ C_3\;,&x\in(4,5) \end{cases}\;. $$
Another more frequently seen example in calculus exercises is the following. Suppose after performing partial fraction decomposition one has $$ f(x)=\frac{1}{x}+\frac{1}{x-1}\;. $$ Note that the natural domain for $f$ is $D=\mathbf{R}\setminus\{0,1\}$, which has three connected components. One usually write $$ \int \frac{1}{x}+\frac{1}{x-1}\;dx = \ln|x|+\ln|x-1|+C $$ which is again, understood as solutions to ($**$) where $I$ is some connected subset of $D$.