Getting Started

Installation

Install evlog in your Nuxt, Nitro, or standalone TypeScript project.

evlog supports multiple environments: Nuxt, Nitro, and standalone TypeScript.

Nuxt

Add evlog as a Nuxt module:

pnpm add evlog

Then add it to your Nuxt config:

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['evlog/nuxt'],
  evlog: {
    env: {
      service: 'my-app',
      environment: process.env.NODE_ENV,
    },
    // Optional: only log specific routes (supports glob patterns)
    include: ['/api/**'],
  },
})

Configuration Options

OptionTypeDefaultDescription
env.servicestring'app'Service name shown in logs
env.environmentstringAuto-detectedEnvironment name
includestring[]undefinedRoute patterns to log. Supports glob (/api/**). If not set, all routes are logged
prettybooleantrue in devPretty print with tree formatting

That's it! You can now use useLogger(event) in any API route.

Nitro

For standalone Nitro projects (without Nuxt), add evlog as a plugin:

nitro.config.ts
export default defineNitroConfig({
  plugins: ['evlog/nitro'],
})
For early Nitro v3 support, use evlog/nitro/v3 instead of evlog/nitro.

Standalone TypeScript

For scripts, workers, CLI tools, or any TypeScript project:

scripts/sync-job.ts
import { initLogger, createRequestLogger } from 'evlog'

// Initialize once at startup
initLogger({
  env: {
    service: 'my-worker',
    environment: 'production',
  },
})

// Create a logger for each operation
const log = createRequestLogger({ jobId: job.id })
log.set({ source: job.source, target: job.target })
log.set({ recordsSynced: 150 })
log.emit() // Manual emit required in standalone mode
In standalone mode, you must call log.emit() manually. In Nuxt/Nitro, this happens automatically at request end.

TypeScript Configuration

evlog is written in TypeScript and ships with full type definitions. No additional configuration is required.

evlog requires TypeScript 5.0 or higher for optimal type inference.

Next Steps

  • Quick Start - Learn the core concepts and start using evlog