Getting Started

On this page

Getting Started

Requirements

  • BoxLang 1.19 or newer. The module is built against 1.19.0-snapshot.
  • Java 21.
  • A BoxLang web runtime: MiniServer, a servlet container or CommandBox.

Install

Current release: 1.0.0.

install-bx-module bx-lens
box install bx-lens

Enable

Lens ships with everything off. It has two surfaces, and you turn each one on by itself in boxlang.json, under modules.bxLens.settings.

{
	"modules": {
		"bxLens": {
			"settings": {
				"bar": { "enabled": true }
			}
		}
	}
}

The bar shows on HTML pages for callers on the same machine (bar.access defaults to "local").

{
	"modules": {
		"bxLens": {
			"settings": {
				"console": {
					"enabled": true,
					"password": "bxsecret:..."
				}
			}
		}
	}
}

The console lives at /~bxlens/index.bxm and needs a password. A plain password works for a quick try, and "${env.BXLENS_PASSWORD}" reads it from an environment variable. For an encrypted value, make the bxsecret: value with BoxLang:

boxlang generatesecret "a long random password"
# bxsecret:AbCdEf123...==

Paste the whole output into console.password. If you start without a password, the console page tells you the same steps in three tabs: Encrypted, Environment variable and Plain text. If several servers share one config, they need the same secret seed, see Set passwords: plain, env or bxsecret. More about the console in Console.

Restart the runtime. Every other setting has a default, so this is all you need. See Configuration for the rest. For a server that real users reach, read Running Lens in production first.

See the bar

Create a page and load it from the same machine.

<bx:output>
	<h1>Hello Lens</h1>
</bx:output>

Open the page. A health strip appears at the bottom.

The collapsed health strip

Click the strip, a chip, or press Ctrl+` to open the panel.

The opened panel on the Timeline tab

Add a message and a timer from code:

lensMessage( "Page loaded", "info" );
users = lensMeasure( "load users", () => {
	return queryExecute( "SELECT 1 AS id" );
} );

See the BIF reference for all functions.

Open the console

With the console on, open http://localhost:8085/~bxlens/index.bxm (use your own host and port) and sign in. /~bxlens/index.bxm always works. The short form /~bxlens/ also works when the request reaches BoxLang. On MiniServer that needs a pass predicate, see The console URL. The bar also has an Open console button.

The console login page

Runtime notes

MiniServer

BxLens is tested on MiniServer.

CommandBox

Install the module the usual way and enable it in the server's boxlang.json.

Servlet containers

Lens uses the same request events as MiniServer. MiniServer is the tested runtime, so test your setup and report problems.

How the bar is delivered

The bar adds a block of about 1 KB to the HTML response. Its styles, script, Alpine.js and icons are files that your own server serves under /~bxlens/index.bxm/assets/, with a hash in the URL so a browser keeps them. They hold no request data. The console is a separate page at /~bxlens/index.bxm that serves its own files and makes no request to any other site.

Requirements and limits

  • Lens injects into HTML responses (text/html by default), before the last </body>. Other responses are recorded but show no bar. They are kept in the console history.
  • Callers must pass the access rules. By default only loopback addresses see the bar (bar.access is "local").
  • When a request ends in an uncaught exception or abort, core renders its own error page and Lens cannot inject into it. The request is still recorded in the console history. See Exceptions.

Next steps

Edit this page Download Markdown Last updated Nov 26, 2026, 8:34:30 AM Report an issue