> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-framework/interceptors/core-interception-points/logging-events.md).

# Logging Events

These events are announced when messages are logged inside the BoxLang runtime. They are announced on the **global interceptor pool**.

| Event Name   | Cancellable | Description                                                                                                                        |
| ------------ | :---------: | ---------------------------------------------------------------------------------------------------------------------------------- |
| `logMessage` |      No     | Fired by `bx:log` and `writeLog()` for every log entry. The actual log writing is handled by interceptors listening to this event. |

* [`logMessage`](#logmessage)

## logMessage

Fired by both the `bx:log` component and the `writeLog()` BIF for every log call. The event data struct is passed **directly** from the caller's attributes/arguments — the actual writing to log files is performed by interceptors that listen to this event (including the built-in logging interceptor). This means you can intercept, suppress, enrich, or redirect any log message in the system.

If `application=true` and an application context is active, an `applicationName` key is automatically added to the data before the event fires.

### Data Structure

| Data Key          | Type      | Description                                                                                             |
| ----------------- | --------- | ------------------------------------------------------------------------------------------------------- |
| `text`            | `String`  | The message text to log.                                                                                |
| `type`            | `String`  | The log level. One of `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`. Defaults to the runtime default level. |
| `log`             | `String`  | The target logger name or absolute file path. Defaults to `application` (the application log).          |
| `application`     | `Boolean` | Whether to include the application name alongside the message. Defaults to `true`.                      |
| `applicationName` | `String`  | The current application name. Added automatically when `application=true` and an app context exists.    |
| `file`            | `String`  | *(Compat only — use `log` instead.)* Legacy file destination.                                           |

### Example

```groovy
class myListener{
	function logMessage( struct data ){
		var text            = data.text;
		var type            = data.type;
		var log             = data.log;
		var applicationName = data.applicationName ?: "";
		// Route, enrich, suppress, or forward log messages
	}
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://boxlang.ortusbooks.com/boxlang-framework/interceptors/core-interception-points/logging-events.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
