Skip to content

About

🦊 Logixlysia is a logger for ElysiaJS

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

276 stars

Watchers

2 watching

Forks

Latest commit

Β 

History

1,309 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🦊 Logixlysia

Logixlysia is a logging library for ElysiaJS Logixlysia

πŸ“© Installation

bun add logixlysia

Works with Elysia 1.4 and the Elysia 2 prereleases. To try Elysia 2, install it from its rc tag (bun add elysia@rc). On Elysia 2 the plugin's types still describe Elysia 1.4: log and store work at run time but are not part of a handler's context type, so TypeScript reports Property 'log' does not exist on the example below. See what changes on Elysia 2.

πŸ“ Usage

Add the plugin, then log from a handler with log. Fields you add with log.mergeContext land on that request's access line.

import { Elysia } from 'elysia'
import logixlysia from 'logixlysia'

new Elysia()
  .use(logixlysia())
  .get('/users/:id', ({ log, params }) => {
    log.mergeContext({ userId: params.id })
    return { id: params.id }
  })
  .listen(3000)

GET /users/42 prints this when the output is piped or colors are off:

2026-11-12T05:54:29.847Z INFO  GET     /users/42 200 1ms
  └─ userId  42

Configuration

import { Elysia } from 'elysia'
import logixlysia from 'logixlysia' // or import { logixlysia } from 'logixlysia'

const app = new Elysia({
  name: 'Elysia with Logixlysia'
})
  .use(
    logixlysia({
      config: {
        service: 'api-server',
        showStartupMessage: true,
        startupMessageFormat: 'banner',
        showContextTree: true,
        contextDepth: 2,
        slowThreshold: 500,
        verySlowThreshold: 1000,
        timestamp: {
          translateTime: 'yyyy-mm-dd HH:MM:ss.SSS'
        },
        ip: true
      }
    })
  )
  .get('/', () => {
    return { message: 'Welcome to Basic Elysia with Logixlysia' }
  })

app.listen(3000)

Choosing which routes are logged

logFilter takes path globs, so health checks and static assets stay out of your logs. A request whose pathname matches exclude, or misses a non-empty include, writes nothing: no access line, no log.* lines from its handler, no error line, no WebSocket lines. exclude wins over include. ** crosses /; * and ? do not.

logixlysia({
  config: {
    logFilter: {
      include: ['/api/**'],
      exclude: ['/api/internal/**']
    }
  }
})

πŸ§ͺ Testing

Assert on what a route logs with the in-memory transport from logixlysia/testing:

import { Elysia } from 'elysia'
import logixlysia from 'logixlysia'
import { createMemoryTransport } from 'logixlysia/testing'

const memory = createMemoryTransport()
const app = new Elysia()
  .use(
    logixlysia({ config: { transports: [memory], useTransportsOnly: true } })
  )
  .get('/orders/:id', ({ log, params }) => {
    log.info('order loaded', { orderId: params.id })
    return { id: params.id }
  })

await app.handle(new Request('http://localhost/orders/42'))

memory.last() // { level, message, method, path, status, durationMs, requestId, context, error, meta, timestamp }
await memory.waitFor(record => record.message === 'order loaded')

✨ Features

  • Request context: accumulate fields with mergeContext into a context tree. Docs
  • Presets: dev, prod, and json output. Docs
  • File logging: writes to disk with rotation by size, age, or count. Docs
  • Adapters: nine built-in destinations, Axiom, Better Stack, ClickHouse, Datadog, HyperDX, Loki, OTLP, PostHog, and Sentry. Docs
  • Sampling: head and tail sampling controls log volume. Docs
  • Enrichers: add trace, user agent, geo, and size fields to every request. Docs
  • Redaction: autoRedact masks PII by pattern; logixlysia/desertant adds neural redaction. Config docs, Neural redaction docs
  • Structured errors: HttpError carries why, fix, and link. Docs
  • Request IDs: read from the incoming request or generated, when requestId is on (the prod preset turns it on). Docs
  • OpenTelemetry: trace correlation and AI usage metrics on the access log. Docs
  • Testing: logixlysia/testing keeps typed, redacted records in memory so a test can assert on what a route logged. Docs
  • WebSocket logging: lifecycle logs via wrapWs. Docs

πŸ“š Documentation

Check out the website for more detailed documentation and examples.

Using a coding agent? The repo ships an agent skill with the API and conventions.

πŸ“„ License

Licensed under the MIT License.

About

🦊 Logixlysia is a logger for ElysiaJS

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

276 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages