Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?


Returns the natural logarithm of a number.




The number argument can be any valid numeric expression greater than 0. Specifying 0 or a negative number results in a runtime error.


The natural logarithm is the logarithm to the base e. The constant e (Exp(1)) is approximately 2.718282.

You can calculate base-n logarithms for any number x by dividing the natural logarithm of x by the natural logarithm of n as follows:

Logn(x) = Log(x) / Log(n)

In ObjectScript, the equivalent function is the $ZLN function, which returns the natural logarithm. The $ZLOG function returns the base-10 logarithm. Please note that Log and $ZLOG are not equivalent functions.


The following example uses the Log function to calculate the natural logarithm for each of the integers 1 through 10:

For x = 1 To 10
Println "Natural log of ",x," = ",Log(x)

The following example uses the Log function to calculate the base-10 logarithms for the numbers 10 through 100, counting by tens. For 100, it returns 2 (10 to the power of x = 100).

x = 10
For y = 1 To 10
Base10 = Log(x) / Log(10)
Println "Base-10 log of ",x," = ",Base10
x = x + 10

See Also