Klarety

Logs

Keep what your live app prints, for 1 to 30 days, and read the last hour.

Logs are what your live app prints: requests, warnings and errors. Use them to find out why a live app misbehaves. They are off until you turn them on.

For why a itself failed, use See why on the deploy (see Deploy an app). For an 's runs, use Log and files on the run (see Runs and approvals).

Before you start

Logs cost by the gigabyte kept

They are off by default. Your spend shows in SettingsUsage & limits (see Credits).

  • A deployed .
  • To turn logs on or off, you need to be able to change the project.

Turn logs on

Open the project's settings

Open the project from Projects, go to Settings (see Project settings) and choose the Deploy section ("How your app runs once it is live, where it deploys from, and what it prints").

Turn on Keep logs

Under Logs, turn on Keep logs. It takes effect within a minute, no new deploy needed.

Choose how long to keep them

Under Keep for, choose 1, 3, 5, 7, 14 or 30 days. Older lines are removed on their own.

The Logs section in a project's Deploy settings
from klarety import Nexus

nx = Nexus.connect()
print(nx.projects.logs("PROJECT_ID"))
nx.projects.set_logs("PROJECT_ID", enabled=True, days=7)

days is one of 1, 3, 5, 7, 14 or 30. set_logs(..., enabled=False) turns them off.

Read the last hour

Last hour shows the newest lines your app printed; select Refresh for more. When nothing was printed, it says "Nothing printed in the last hour."

for line in nx.projects.log_lines("PROJECT_ID", minutes=60):
    print(line)

api_lines = nx.projects.log_lines("PROJECT_ID", minutes=15, service="api")

Lines come newest last. Pass service to read one part of the app. The answer is empty while logs are off.

What you see when it worked

Within a minute, new lines appear under Last hour. If the app is quiet, open it with Visit and select Refresh.

Choose how long to keep logs

A longer period costs more for a busy app.

  • 1 or 3 days suit day-to-day checks.
  • 7 or 14 days help when a problem shows up only now and then.
  • 30 days suits an app where you need to look back over a month.

Change the period or turn logs off at any time.

If something goes wrong

  • Nothing shows under Last hour: check that Keep logs is on, then give it a minute. An app that Sleeps when idle prints nothing while asleep; visit it to wake it.
  • The app prints too much: lower the period, or have the app log less (for example, only warnings and errors).
  • A new version failed many requests and visitors went back to the one before: read the logs for those errors, fix them and deploy again.

Where to go next

On this page