Skip to main content

$log

The $log operator returns the logarithm of the first value with the second value as the base.

Input

  • An array containing exactly two numeric values: the input value and the base

Output

  • The logarithm of the first value with the second value as the base

Examples

Natural Log (base e)

{
  "$log": [
    2.718281828,
    2.718281828
  ]
}
Result: 1 (approximately)

Base 10 Log

{
  "$log": [
    100,
    10
  ]
}
Result: 2

Base 2 Log

{
  "$log": [
    8,
    2
  ]
}
Result: 3

Field Value

{
  "$log": [
    {
      "$input": "value"
    },
    {
      "$input": "base"
    }
  ]
}
Result: The logarithm of the value field with the base field as the base