Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fnumber%2Flog.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fnumber%2Flog.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `log`

## Description

Returns the logarithm of a number to a specified base. Common uses include modeling compound interest, exponential growth or decay, pH levels, and earthquake magnitudes.

## Syntax

Like many functions in DataPrime, `log` supports<!-- --> [two notations](https://docs-docusaurus.kinsta.page/dataprime/language-reference/functions-reference/.md),<!-- --> **function** and **method**. These interchangeable forms allow flexibility in how you structure expressions.

* Function notation
* Method notation

```
log(base: number, number: number): number
```

```
(base: number).log(number: number): number
```

## Arguments

| Name     | Type     | Required | Description                                    |
| -------- | -------- | -------- | ---------------------------------------------- |
| `base`   | `number` | **true** | The logarithmic base (e.g. `2` for log base 2) |
| `number` | `number` | **true** | The value whose logarithm will be computed     |

## Example

**Use case: Compute a log base 2 transformation**

Calculate the log base 2 of a numerical field and store the result in a new field.

### Example data

```
{

    "some_value": 16

}
```

### Example query

* Function notation
* Method notation

```
create log_field from log(2, some_value)
```

```
create log_field from 2.log(some_value)
```

### Example output

```
{

    "some_value": 16,

    "log_field": 4

}
```
