> For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt.

# 日志事件

日志事件是由 Modern.js 分发的，类型为 `log` 的事件。

## 内置事件

基于服务端运行逻辑，Modern.js 在内部提供了以下日志事件：

| 阶段             | 消息                                            | Level |
| -------------- | --------------------------------------------- | ----- |
| RENDER\_HTML   | App Render To HTML                            | error |
| RENDER\_STREAM | An error occurs during streaming SSR          | error |
| RENDER\_SHELL  | An error occurs during streaming render shell | error |

## 内置 Monitor

在 Modern.js 中，日志事件由 LoggerMonitor 处理，它会将日志输出到控制台。

:::info
内置的 LoggerMonitor 依赖了 [rslog](https://www.npmjs.com/package/rslog) 库。
:::

例如在项目中有意的抛出一个错误：

```tsx title=routes/page.tsx
import './index.css';

const Index = () => <div className="container-box">{a}</div>;

export default Index;
```

如果运行正常，可以在控制台看到如下输出：

```shell
> Local:    http://localhost:8080/
> press h + enter to show shortcuts

error   SSR Error - App Prerender, error = ReferenceError: a is not defined
    at Index (/somepath/page.tsx:3:1)
```
