> ## Documentation Index
> Fetch the complete documentation index at: https://docs.edgespark.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# View EdgeSpark logs

> Use edgespark log tail for live EdgeSpark observability, background log capture, and real-time debugging of deployed requests.

EdgeSpark captures logs from your project's worker and streams them in real time through the CLI.

## Stream logs

```bash theme={null}
edgespark log tail
```

The output includes `console.info`, `console.warn`, `console.error`, uncaught exceptions, and request summaries for each invocation.

<Tip>
  `edgespark log tail` streams from your current default environment. For newly created projects today, that is the single public production environment.
</Tip>

## Recommended observability workflow

For a quick manual check, run `edgespark log tail` in one terminal and trigger requests from another.

For longer debugging sessions, the better pattern is to send the log stream to a file and let it keep running in the background while you deploy, trigger requests, and inspect results separately:

```bash theme={null}
mkdir -p .logs
edgespark log tail > .logs/edgespark.log 2>&1 &
```

This works well when you want to:

* keep logs running while you edit and redeploy
* trigger requests from another shell or browser
* review the stream after the fact instead of watching one long interactive session
* let an agent keep the log stream alive in the background while it checks the file incrementally

## Check the file while requests are running

Once the background stream is running, trigger a request and inspect the file:

```bash theme={null}
curl -i https://my-app.edgespark.app/api/hello
```

For AI agents, the guidance is simple: keep `edgespark log tail` running in the background, write it to `.logs/edgespark.log`, and read that file between deploys, requests, and retries.

That is more reliable than keeping the agent attached to a continuously streaming terminal session. The log file becomes a stable artifact the agent can inspect, summarize, and revisit after each step.

## Log a message from your code

```typescript server/src/index.ts theme={null}
import { db } from "edgespark";
import { auth } from "edgespark/http";
import { Hono } from "hono";
import { posts } from "@defs";

const app = new Hono().post("/api/posts", async (c) => {
  const body = await c.req.json<{ title: string; content?: string }>();

  console.info("Creating post", { title: body.title, userId: auth.user.id });

  try {
    const [post] = await db
      .insert(posts)
      .values({ title: body.title, content: body.content ?? null, authorId: auth.user.id })
      .returning();

    console.info("Post created", { postId: post.id });
    return c.json(post, 201);
  } catch (error) {
    console.error("Post insert failed", { userId: auth.user.id, error });
    return c.json({ error: "Failed to create post" }, 500);
  }
});

export default app;
```

## See also

<Columns cols={2}>
  <Card title="Deploy and test loop" icon="rotate" href="/agents/deploy-and-test">
    How to read logs after a request and iterate on errors.
  </Card>

  <Card title="Development workflow" icon="workflow" href="/guides/development-workflow">
    Where `edgespark log tail` fits in the normal edit, deploy, and validate loop.
  </Card>

  <Card title="CLI commands" icon="terminal" href="/cli/commands">
    Full reference for `edgespark log tail` and the rest of the CLI.
  </Card>

  <Card title="Handling errors" icon="triangle-exclamation" href="/agents/handling-errors">
    How to use runtime logs to debug deploy failures, request errors, and SQL rejections.
  </Card>
</Columns>
