Overview
WLog provides a hierarchy of named loggers that can be configured independently. Every logger has a dotted-path name (e.g.com.freerdp.core.channel). Child loggers inherit their level from the parent unless explicitly overridden, so you can silence everything at the root and selectively enable one subsystem.
The header is winpr/include/winpr/wlog.h. Include it with:
Log levels
Levels are ordered from most-verbose to least-verbose. Setting a level enables that level and all levels above it (i.e., less verbose).Quick start
1
Get a logger
Call
WLog_Get with a dotted tag name. The returned pointer is cached and reused for the lifetime of the process — it is safe to store in a static variable.2
Log messages
Use the Or using the tag macros (logger is looked up once and cached internally):
WLog_Print macro (checks the active level before formatting) or the convenience tag-based macros WLog_DBG, WLog_INFO, WLog_WARN, WLog_ERR, WLog_FATAL.3
Configure via environment (optional)
Full API reference
Logger lifecycle
WLog_Get and WLog_GetRoot return loggers that are owned by WinPR’s internal registry and must not be freed by the caller.
Level control
Printing messages
Convenience macros
These macros inject__LINE__, __FILE__, and __func__ automatically.
Context and prefix
Appender management
Layout
Logging code examples
Environment variables
Filter syntax
WLOG_FILTER accepts a comma-separated list of <logger-name>:<level> pairs:
Format specifiers
TheWLOG_PREFIX environment variable (and WLog_Layout_SetPrefixFormat) uses %-prefixed tokens. Up to 16 tokens may appear in a single format string.
Example:
Appenders
CONSOLE (default)
CONSOLE (default)
Writes to the terminal. On Android, redirects to
__android_log_print. Output stream routing:Configuration key:
outputstream, value: const char*FILE
FILE
Writes formatted text to a file.
BINARY
BINARY
Writes log data in a binary format file — useful for post-processing or tooling that parses structured log records.
UDP
UDP
Sends log messages over UDP to a remote host. Suitable for centralised log aggregation without writing to disk.Receive with netcat:
Default target:
127.0.0.1:20000.SYSLOG (optional, Linux/macOS)
SYSLOG (optional, Linux/macOS)
Routes log messages to the system logger via the POSIX
syslog(3) API. WLog levels are mapped to syslog priorities. No additional options.Requires WinPR to have been built with syslog support (enabled automatically when
<syslog.h> is detected at build time).JOURNALD (optional, systemd)
JOURNALD (optional, systemd)
Sends structured log entries to the systemd journal via View output:
sd_journal_send.Requires WinPR to be built with
WITH_SYSTEMD=ON and libsystemd installed.CALLBACK
CALLBACK
Delivers all log messages to application-provided function pointers. Use this to integrate WLog into an existing logging framework.
Set unused callbacks to
NULL; WLog will skip them.Message types
Beyond plain text, WLog can carry structured payloads. Pass the type constant as the first argument toWLog_PrintMessage.
Packet direction constants:
wLogMessage structure
All appender callbacks receive a const wLogMessage*. Fields of interest:
