RoadRunner
  • 🟠General
    • What is RoadRunner?
    • Features
    • Quick Start
    • Installation
    • Configuration
    • Contributing
    • Upgrade and Compatibility
  • 👷PHP Worker
    • Worker
    • Workers pool
    • Developer mode
    • Code Coverage
    • Debugging
    • Environment
    • Manual workers scaling
    • Auto workers scaling
    • RPC
  • 🟢Customization
    • Building RR with a custom plugin
    • Integrating with Golang Apps
    • Writing a Middleware
    • Writing a Jobs Driver
    • Writing a Plugin
    • Events Bus
  • 🔌Plugins
    • Intro into Plugins
    • Centrifuge (WebSockets)
    • Service (Systemd)
    • Configuration
    • Server
    • Locks
    • gRPC
    • TCP
  • 🌐Community Plugins
    • Intro into Community Plugins
    • Circuit Breaker
    • SendRemoteFile
    • RFC 7234 Cache
  • 🔵App Server
    • Production Usage
    • RoadRunner with NGINX
    • RR as AWS Lambda
    • Docker Images
    • CLI Commands
    • Systemd
  • 🔐Key-Value
    • Intro into KV
    • Memcached
    • In-Memory
    • BoltDB
    • Redis
  • 📦Queues and Jobs
    • Intro into Jobs
    • Google Pub/Sub
    • Beanstalk
    • In-Memory
    • RabbitMQ
    • BoltDB
    • Kafka
    • NATS
    • SQS
  • 🕸️HTTP
    • Intro into HTTP
    • Headers and CORS
    • Proxy IP parser
    • Static files
    • X-Sendfile
    • Streaming
    • gzip
  • 📈Logging and Observability
    • OpenTelemetry
    • HealthChecks
    • Access Logs
    • AppLogger
    • Metrics
    • Grafana
    • Logger
  • 🔀Workflow Engine
    • Temporal.io
    • Worker
  • 🧩Integrations
    • Migration from RRv1 to RRv2
    • Spiral Framework
    • Yii
    • Symfony
    • Laravel
    • ChubbyPHP
  • 🧪Experimental Features
    • List of the Experimental Features
  • 🚨Error codes
    • CRC validation failed
    • Allocate Timeout
  • 📚Releases
    • v2025.1.2
    • v2025.1.1
    • v2025.1.0
    • v2024.3.5
    • v2024.3.4
    • v2024.3.3
    • v2024.3.2
    • v2024.3.1
    • v2024.3.0
Powered by GitBook
On this page
  • Configuration
  • PHP client
  • Installation
  • Usage
  • Available methods
  • API
  • RPC API

Was this helpful?

Edit on GitHub
  1. Logging and Observability

AppLogger

PreviousAccess LogsNextMetrics

Last updated 1 year ago

Was this helpful?

The RoadRunner server has a useful app-logger plugin that allows users to send logs from their applications to the RoadRunner server using an RPC interface. This plugin is enabled by default and does not require any additional configurations. It can be used to observe all application and server logs in one place. This is especially useful when debugging and monitoring applications.

It will send raw messages to the RoadRunner STDERR

Configuration

The logs section in the RoadRunner configuration file allows you to configure logging behavior for their application.

.rr.yaml
rpc:
  listen: tcp://127.0.0.1:6001

logs:
  channels:
    app:
      level: info

To interact with the RoadRunner app-logger plugin, you will need to have the RPC defined in the rpc configuration section. You can refer to the documentation page to learn more about the configuration.

The level key is used to specify the logging level for this channel. This means that only log messages with a severity level of info or higher will be sent to this channel.

Read more about logging in the section.

PHP client

The RoadRunner app-logger plugin comes with a convenient PHP package that simplifies the process of integrating the plugin with your PHP application.

Installation

To get started, you can install the package via Composer using the following command:

composer require roadrunner-php/app-logger

Usage

After the installation, you can create an instance of the RoadRunner\Logger\Logger class, which will allow you to use the available class methods.

Here is an example:

logger.php
use Spiral\Goridge\RPC\RPC;
use RoadRunner\Logger\Logger;

$rpc = RPC::create('tcp://127.0.0.1:6001');

$logger = new Logger($rpc);

$logger->info('Hello, RoadRunner!');
$logger->warning('Something might be wrong...');
$logger->error('Houston, we have a problem!');

Available methods

  • debug(string): void: Sends a debug log message to the server

  • error(string): void: Sends an error log message to the server

  • info(string): void: Sends an info log message to the server

  • warning(string): void: Sends a warning log message to the server

  • log(string): void: Sends a log message directly to the STDERR of the server

API

RPC API

RoadRunner provides an RPC API, which allows you to manage app-logger in your applications using remote procedure calls. The RPC API provides a set of methods that map to the available methods of the RoadRunner\Logger\Loggerclass in PHP.

All methods accept a string (which will be log message) as a first argument and a bool placeholder for the second arg.

Error

Method sends an error log message with the specified message to the RoadRunner server.

func (r *RPC) Error(in string, _ *bool) error {}

Info

Method sends an info log message with the specified message to the RoadRunner server.

func (r *RPC) Info(in string, _ *bool) error {}

Warning

Method sends a warning log message with the specified message to the RoadRunner server.

func (r *RPC) Warning(in string, _ *bool) error {}

Debug

Method sends a debug log message with the specified message to the RoadRunner server.

func (r *RPC) Debug(in string, _ *bool) error {}

Log

Method sends a log message with the specified message directly to the STDERR of the RoadRunner server.

func (r *RPC) Log(in string, _ *bool) error {}

You can refer to the documentation page to learn more about creating the RPC connection.

📈
here
Logging — Logger
here