Skip to content

Logger

The logger interface is exposing a logger function which is backed by pino.

This should be used to log all server related information to create structured logs.

import { logger } from '@pit-shared/remix-runtime/logger'

export async function loader() {
    try {
        logger().debug('Handle request...')
        logger().info('Handle request...')
        logger().warn('Handle request...')
    } catch (err) {
        logger().error({ err }, 'An error occurred')
    }
}

Access Logs

The runtime automatically supports structured access logging compatible with Datadog log processing pipelines. Access logs are opt-in and should be enabled for applications behind CDN but not for internal systems.

Enabling Access Logs

To enable access logs, set the ENABLE_ACCESS_LOGS environment variable:

ENABLE_ACCESS_LOGS=true

Access Log Format

When enabled, the logger will output structured JSON access logs for each HTTP request:

{
    "service": "my-remix-app",
    "http": {
        "referer": "https://example.com/previous-page",
        "status_code": 200,
        "method": "GET",
        "useragent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
        "version": "1.1",
        "url": "/statistik/daten/studie/1288395/umfrage/"
    },
    "timestamp": 1758555624108,
    "network": {
        "edge": {
            "ip": "15.158.226.98"
        },
        "client": {
            "ip": "81.220.150.213"
        }
    }
}

Network Information

The access logs automatically extract network information from the X-Forwarded-For header:

  • network.client.ip: The first IP in the X-Forwarded-For header, representing the real client IP
  • network.edge.ip: The last IP in the X-Forwarded-For header, representing the CDN edge server IP

If the X-Forwarded-For header is missing, the network field will be omitted from the log entry.

Datadog Processing

The following fields are automatically added through Datadog log processors:

Configuration

The service name in access logs is automatically determined from the DD_SERVICE environment variable, falling back to "remix-app" if not set.