\log and \ln are operator names, so LaTeX prints them upright and puts the right space before the argument. Typing plain log gives italic l, o, g, which reads as three variables multiplied together. Put the base in a subscript: \log_2 n.
All ways to write it
\loglogarithm, printed uprightNo package needed\lnnatural logarithmNo package needed\log_{b} xlogarithm to base bNo package needed\lgshort log, base 10 or 2 depending on the fieldNo package needed\expexponential function, the inverse of \lnNo package needed\operatorname{lb}any other operator name, e.g. binary logPackage: amsmath
Commands marked with a package need that \usepackage line in a LaTeX document.
Example
\log_b(xy) = \log_b x + \log_b yThe product rule for logarithms.
Questions
How do I write log base 2 in LaTeX?
\log_2 n. Use braces when the base has more than one character: \log_{10} x.
Why does my log look italic?
You typed log as letters. Use \log (or \ln) so it prints upright with operator spacing.
How do I make parentheses after \log scale?
Use \left( and \right): \log\left(\frac{a}{b}\right). Plain parentheses stay at normal height.
How do I add an operator that isn't built in?
\operatorname{lb} prints any name upright with operator spacing. It comes from amsmath and works in KaTeX, so it works in Confluence math macros.
Using logarithm in Confluence
Confluence Cloud has no built-in LaTeX. With LaTeX Math for Confluence you add a math macro to any page, type \log and it renders inline or as a block, with a live preview while you edit. Every command on this page renders there without extra packages.