Quick start

Get LogReader running in your Laravel application in a few steps:

  1. Install the package:
    composer require mvd81/laravel-logreader
  2. Publish the config:
    php artisan vendor:publish --tag=logreader-config
  3. Create an app in your LogReader dashboard
  4. Copy the API token and add it to your .env:
    LOGREADER_ENABLED=true
    LOGREADER_TOKEN=your-api-token-here
  5. Your logs will now appear in the LogReader dashboard

Configuration

Publish the configuration file:

php artisan vendor:publish --tag=logreader-config

Add the following environment variables to your .env file:

LOGREADER_ENABLED=true
LOGREADER_TOKEN=your-api-token-here

You can find your API token in the Apps section of your dashboard after creating an app.


How it works

Once installed and configured, the package allows LogReader to securely connect to your Laravel application using your token to read, search, and filter your log files in real time.

All file access is restricted to your application's storage/logs directory. Every request is validated with your token and path traversal attacks are prevented.


Excluding log files

Although LogReader does not store your log data, your logs may contain sensitive information such as passwords, tokens, or personal data. To prevent this information from being visible to other users with access to your dashboard, you can exclude specific log files or directories.

Set the LOGREADER_EXCLUDE_LOGS environment variable with a comma-separated list of patterns:

LOGREADER_EXCLUDE_LOGS=passwords.log,private/*,*.tmp

Supported patterns:

  • Exact filenames: passwords.log
  • Directory paths: private/*
  • Wildcards: *.tmp, cache*

Deployments

LogReader can track deployment history for each of your apps. Every deployment — successful or failed — appears in a timeline with its status, message, branch, and timestamp. You can filter by read/unread and receive browser push notifications on arrival.

The central Deployments page in the dashboard shows all deployments across every app you have access to in one overview.


API endpoint

Report a deployment by sending a POST request to:

POST /api/apps/{app_id}/deployments

Authenticate with your app's token as a Bearer token:

Authorization: Bearer your-app-token

Request body (JSON):

Field Type Required Description
status string Yes info, success, or failed
message string No Short description, e.g. "Deploy started", an error message, or "Deploy completed successfully."
branch string No The git branch that was deployed, e.g. main, staging

Each request creates a new timeline entry. You can call this endpoint multiple times during a deploy — for example to log the start, intermediate steps, and the final result.

Example with curl:

curl -X POST https://logreader.dev/api/apps/1/deployments \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-app-token" \
  -d '{"status": "success", "message": "Deploy completed successfully.", "branch": "main"}'

Deploy script

Add the following variables to your .env file on the server you deploy from:

LOGREADER_URL=https://logreader.dev
LOGREADER_APP_ID=1
LOGREADER_TOKEN=your-app-token

You can find both the App ID and Token in the Apps section of your dashboard — the ID is shown in the first column of the table.

Add this function to your deploy script:

notify_logreader() {
    local status="$1"
    local message="${2:-}"
    if [ -n "$LOGREADER_URL" ] && [ -n "$LOGREADER_APP_ID" ] && [ -n "$LOGREADER_TOKEN" ]; then
        local logreader_status="$status"
        [ "$status" = "fail" ] && logreader_status="failed"
        curl -s -X POST "${LOGREADER_URL}/api/apps/${LOGREADER_APP_ID}/deployments" \
            -H "Content-Type: application/json" \
            -H "Authorization: Bearer ${LOGREADER_TOKEN}" \
            -d "{\"status\":\"${logreader_status}\",\"message\":\"${message}\",\"branch\":\"${GIT_BRANCH}\"}" \
            > /dev/null || true
    fi
}

# At the start of your deploy:
notify_logreader info "Deploy started."

# Optionally log intermediate steps:
notify_logreader info "Migrations complete."

# On success:
notify_logreader success "Deploy completed successfully."

# On failure:
notify_logreader fail "migrate failed: error message here."

Configuration options

Option Environment variable Default Description
enabled LOGREADER_ENABLED true Enable or disable the LogReader API
token LOGREADER_TOKEN null API token for authenticating requests
exclude_logs LOGREADER_EXCLUDE_LOGS '' Comma-separated list of files or patterns to exclude