# Integral of ln x: Formula, Steps and Examples

> The integral of ln x is x ln x − x + C. See the integration by parts steps, a check by differentiating, a graph and examples like ln(2x) and (ln x)².

Source: https://practicecalculus.com/integrals/ln-x
Updated: 2026-11-06

$$ \int \ln x\,dx = x\ln x - x + C $$

## At a glance

- **Antiderivative:** $x\ln x - x + C$
- **Method:** Integration by parts with $u = \ln x$, $dv = dx$
- **From 1 to e:** $1$
- **From 0 to 1:** $-1$ (improper, converges)
- **Base-b log:** $\int \log_b x\,dx = \frac{x\ln x - x}{\ln b} + C$

## Key takeaways

- The integral of $\ln x$ is $x\ln x - x + C$, which you can also write $x(\ln x - 1) + C$.
- Use integration by parts with $u = \ln x$ and $dv = dx$. The leftover integral is just $\int 1\,dx$.
- The answer is not $\frac{1}{x}$. That is the derivative of $\ln x$.
- Repeating the trick handles $(\ln x)^2$, $(\ln x)^3$ and so on.

The **integral of $\ln x$ is $x\ln x - x + C$**. There is no reverse rule that undoes the log directly, so the standard method is integration by parts with a hidden factor of $1$.

$$\int \ln x\,dx = x\ln x - x + C$$

## Graph of ln x and its antiderivative

```graph
title: 'y = ln x and its antiderivative x ln x − x'
caption: 'The shaded area from $1$ to $e$ is exactly $1$. The dashed antiderivative has its minimum at $x = 1$, where $\ln x$ changes from negative to positive.'
x: [-0.5, 5]
y: [-2.5, 3.5]
functions:
  - expr: ln(x)
    label: y = ln x
    domain: [0.05, 5]
  - expr: x*ln(x) - x
    label: y = x ln x − x (antiderivative)
    dashed: true
    domain: [0.01, 5]
shade:
  expr: ln(x)
  from: 1
  to: 2.71828
points:
  - [1, 0, '(1, 0)']
  - [1, -1, '(1, −1)']
```

## How to integrate ln x step by step

Use [integration by parts](/rules/integration-by-parts-rule), $\int u\,dv = uv - \int v\,du$.

1. **Write $\ln x$ as a product.** $\int\ln x\,dx = \int \ln x\cdot 1\,dx$.
2. **Choose the parts.** $u = \ln x$ and $dv = dx$. Then $du = \frac{1}{x}\,dx$ and $v = x$.
3. **Apply the formula.**
$$\int \ln x\,dx = x\ln x - \int x\cdot\frac{1}{x}\,dx = x\ln x - \int 1\,dx$$
4. **Finish.** $\int 1\,dx = x$, so the answer is $x\ln x - x + C$.

Why does this work? Differentiating $\ln x$ turns it into $\frac{1}{x}$, which cancels the $x$ from $v$. In the LIATE order, logs come first, so they almost always play the role of $u$. The [integration by parts guide](/blog/integration-by-parts) has more on choosing $u$.

## Check by differentiating

By the [product rule](/rules/product-rule) and the [derivative of ln x](/derivatives/ln-x):

$$\frac{d}{dx}\left(x\ln x - x\right) = \ln x + x\cdot\frac{1}{x} - 1 = \ln x + 1 - 1 = \ln x$$

## Definite integrals

**From 1 to e:**

$$\int_1^e\ln x\,dx = (e\cdot 1 - e) - (1\cdot 0 - 1) = 0 + 1 = 1$$

**From 1 to 2:** $(2\ln 2 - 2) - (0 - 1) = 2\ln 2 - 1 \approx 0.386$.

**From 0 to 1:** this is an [improper integral](/blog/improper-integrals) since $\ln x \to -\infty$ near $0$. Using the limit $x\ln x \to 0$ as $x \to 0^+$:

$$\int_0^1 \ln x\,dx = (0 - 1) - \lim_{a\to 0^+}(a\ln a - a) = -1$$

The answer is negative because $\ln x < 0$ on $(0, 1)$, so the area lies below the axis.

## Worked examples

**Example 1: a constant inside.** $\int\ln(2x)\,dx$. Let $u = 2x$, $dx = \frac{du}{2}$:

$$\frac{1}{2}(u\ln u - u) + C = x\ln(2x) - x + C$$

**Example 2: a shifted log.** $\int\ln(x+1)\,dx$. Let $u = x + 1$, $du = dx$:

$$(x+1)\ln(x+1) - (x+1) + C$$

The $-1$ can be absorbed into $C$, so $(x+1)\ln(x+1) - x + C$ is also correct.

**Example 3: a squared log.** $\int(\ln x)^2\,dx$. Take $u = (\ln x)^2$, $dv = dx$, so $du = \frac{2\ln x}{x}\,dx$ and $v = x$:

$$\int(\ln x)^2\,dx = x(\ln x)^2 - 2\int\ln x\,dx = x(\ln x)^2 - 2x\ln x + 2x + C$$

**Example 4: a power of x inside.** $\int\ln(x^3)\,dx = 3\int\ln x\,dx = 3x\ln x - 3x + C$, after the log rule $\ln(x^3) = 3\ln x$.

**Example 5: base 10.** Since $\log_{10}x = \frac{\ln x}{\ln 10}$, $\int\log_{10}x\,dx = \frac{x\ln x - x}{\ln 10} + C$.

## Common mistakes

1. **Answering $\frac{1}{x}$.** That is the derivative of $\ln x$. The integral of $\frac{1}{x}$ is $\ln\lvert x\rvert$; see the [integral of 1/x](/integrals/1-over-x).
2. **Choosing $u = 1$, $dv = \ln x\,dx$.** Then you need $\int\ln x\,dx$ to find $v$, the very thing you are trying to compute.
3. **Losing the $-x$.** $x\ln x$ alone has derivative $\ln x + 1$, one too many.
4. **Confusing $\ln x$ with $\frac{\ln x}{x}$.** $\int\frac{\ln x}{x}\,dx = \frac{(\ln x)^2}{2} + C$ is a [u-substitution](/rules/u-substitution-rule), not a parts problem.

For a log times a power of $x$, see the [integral of x ln x](/integrals/x-ln-x). For logs in the denominator, see the [integral of 1/(x ln x)](/integrals/1-over-x-ln-x).

## Frequently asked questions

### What is the integral of ln x?

It is $x\ln x - x + C$, for $x > 0$.

### What is the integral of ln(2x)?

It is $x\ln(2x) - x + C$. Since $\ln(2x) = \ln 2 + \ln x$, you can also integrate the pieces and get $x\ln 2 + x\ln x - x + C$, which is the same thing.

### What is the integral of (ln x)²?

It is $x(\ln x)^2 - 2x\ln x + 2x + C$. Use parts with $u = (\ln x)^2$, $dv = dx$, then use the integral of $\ln x$ for the leftover piece.

### What is the integral of ln x from 0 to 1?

It is $-1$. It is improper because $\ln x \to -\infty$ at $0$, but $x\ln x \to 0$, so the integral is $(0 - 1) - 0 = -1$.
