AppLogger
The app-logger plugin accepts log messages over RPC. Level-based methods use the app logger channel. The log() method writes directly to RoadRunner's standard error.
Configuration
Configure the app channel in the logs section to select the output format and minimum level:
rpc:
listen: tcp://127.0.0.1:6001
logs:
channels:
app:
mode: production
level: infoThis example emits JSON records at info level or higher and filters out debug. These settings do not control raw log calls.
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:
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:
Available methods
debug(string): void: Sends a debug log message to the servererror(string): void: Sends an error log message to the serverinfo(string): void: Sends an info log message to the serverwarning(string): void: Sends a warning log message to the serverlog(string): void: Sends a log message directly to theSTDERRof the server
Raw Output
The raw RPC methods app.Log and app.LogWithContext write directly to standard error. They bypass logger levels, formats, output settings, and the asynchronous queue. These calls wait for the write to complete. The logger's raw mode uses its configured level, destinations, and asynchronous queue.
With app-logger v6, app.Log appends LF (\n) only when the message does not already end with LF. app.LogWithContext uses the same rule when there are no attributes. V5 wrote these messages without adding a line ending. Update consumers that depended on concatenated messages without line endings.
With attributes, app.LogWithContext writes the message, a space, comma-separated key:value pairs, and LF. It preserves newlines inside the message. Send the raw RPC message without a trailing newline if you need the attributes on the same line.
API
RPC API
The string methods accept a message and a boolean reply placeholder. Call them by their registered RPC names:
app.Error
Error-level record through the app logger.
app.Info
Info-level record through the app logger.
app.Warning
Warning-level record through the app logger.
app.Debug
Debug-level record through the app logger.
app.Log
Raw standard error output.
Each method also has a WithContext variant, such as app.InfoWithContext. These methods accept LogEntry and a Response placeholder from github.com/roadrunner-server/api-go/v6/applogger/v1. The entry carries the message and LogAttrs key/value pairs.
The plugin's Go RPC receiver is no longer exported as app.RPC. Custom containers obtain it through Plugin.RPC(); PHP RPC method names are unchanged.
Last updated