NewSchokr 13 is here. A whole new UI, seven locations, snapshots and more. Read more →

How to read your Discord bot's logs in the Schokr console

Find errors in your bot's console output on Schokr, read a stack trace, fix missing Python output and save logs to a file you can open later.

Updated · 2 min read

Everything your bot prints (with console.log, print or a logger) and every error it throws appears in your server's console on Schokr. When something breaks, the console is the first place to look.

Where to find it

  1. Open the Schokr console and select your bot's server.
  2. Open the server's console view. Output appears live while the server runs.
  3. Start or restart the server and watch from the beginning to catch startup errors.

The console shows recent output. If you need history across restarts, write logs to a file too (see below).

What a healthy start looks like

For a Node.js bot, you'll typically see package installation, then your own output:

added 32 packages in 3s
Logged in as MyBot#1234

For Python, pip output followed by discord.py's log lines:

INFO     discord.client logging in using static token
INFO     discord.gateway Shard ID None has connected to Gateway
Logged in as MyBot#1234

How to read a stack trace

Errors print as a message plus a list of the places in the code that led to it.

DiscordAPIError[50013]: Missing Permissions
    at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:727:13)
    at async Object.execute (/home/container/commands/ban.js:14:5)
  • The first line is what went wrong.
  • Find the first line that points to your own files (not node_modules or site-packages). That's where to look. Here, commands/ban.js line 14.
  • In Python tracebacks, read from the bottom: the last line is the error, the lines above it are the call path, and your files are the ones to check.

Python output not showing up

When output isn't going to a terminal, Python can buffer print() and show it late or not at all before a crash. Fix it with any of:

  • print("message", flush=True)
  • Using the logging module instead of print.
  • Setting the environment variable PYTHONUNBUFFERED=1 if your startup command allows it.

Log to a file as well

A log file lets you look back after restarts. Read it in the file manager.

Python:

import logging

handler = logging.FileHandler("bot.log", encoding="utf-8", mode="a")
bot.run(TOKEN, log_handler=handler, log_level=logging.INFO)

Node.js, a minimal version:

const fs = require('node:fs');
const logFile = fs.createWriteStream('bot.log', { flags: 'a' });

function log(...args) {
  const line = `[${new Date().toISOString()}] ${args.join(' ')}`;
  console.log(line);
  logFile.write(line + '\n');
}

For bigger bots, a logging library such as pino or winston adds levels and rotation. Keep an eye on file size, since logs count toward your disk space; delete or rotate old logs.

Typing in the console

Text you type in the console is sent to your bot's standard input. Most bots ignore it, so typing commands there doesn't do anything unless your code reads input. Use the power controls to start, stop and restart.

Don't leak your token

Never log your token or the full config object. If you share logs for help, scan them first. If a token did end up in a log someone else saw, reset it; see storing your token safely.

Next steps