SDK Configuration

Initialize OneMinute Logs

Initialize OneMinute Logs once when your application starts.

After initialization, you can import the logger anywhere in your project and start sending events.

Create a logger

// lib/logs.ts
import { createLogger } from "@oneminutelogs/next";

export const log = createLogger({
  apiKey: process.env.ONE_MINUTE_LOGS_API_KEY!,
  appName: "my-next-app",
  environment: process.env.NODE_ENV ?? "development",
});

Configuration options

OptionRequiredDescription
apiKeyYesYour OneMinute Logs API key.
appNameYesThe name of your application.
environmentNoEnvironment name (development, staging, production). Defaults to development.

Using the logger

Once configured, import it anywhere.

import { log } from "@/lib/logs";

Now you're ready to send events.

Important

Do not call log.info(), log.error(), or any other logging method from client-side or frontend code. Keep your logger on the server so your API key stays private.

Best practices

Initialize only once

Create a single logger instance and reuse it throughout your application.

Good

export const log = createLogger({...});

Don't

createLogger({...});
createLogger({...});
createLogger({...});

Never hardcode your API key

Always load it from environment variables.

apiKey: process.env.ONE_MINUTE_LOGS_API_KEY

Use meaningful application names

Good

becodemy

oneminutelogs

billing-service

Avoid

app

test

project

Set the correct environment

environment: "production"
environment: "staging"
environment: "development"

This makes filtering events much easier later.

What happens after initialization?

Once the logger is initialized, OneMinute Logs automatically:

  • Authenticates every request using your API key.
  • Buffers events in memory to minimize network overhead.
  • Automatically batches events for better performance.
  • Flushes logs in the background without blocking your application.

You only need to call log.info(), log.error(), or the other logging methods. See Event Fields for all available event types.

No manual setup required

Once initialized, OneMinute Logs automatically batches events, retries failed requests, and flushes them in the background. There are no background workers, queues, or cron jobs for you to configure.

What's next?

Now that your logger is configured, let's send your first production event.

Found something unexpected? Let us know.