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).| Constant | Value | Description |
|---|---|---|
WLOG_TRACE | 0 | Everything, including raw packet/data dumps |
WLOG_DEBUG | 1 | Debug messages |
WLOG_INFO | 2 | General informational messages |
WLOG_WARN | 3 | Warnings about unexpected but recoverable conditions |
WLOG_ERROR | 4 | Errors that affect functionality |
WLOG_FATAL | 5 | Fatal problems — the application cannot continue |
WLOG_OFF | 6 | Completely disables all output for this logger |
WLOG_LEVEL_INHERIT | 0xFFFF | Inherit the level from the parent logger (default) |
Quick start
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.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.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.
| Macro | Description |
|---|---|
WLog_Print(log, level, ...) | Check level, then log a text message via a wLog* |
WLog_Print_unchecked(log, level, ...) | Log without checking level first |
WLog_PrintVA(log, level, fmt, args) | va_list variant of WLog_Print |
WLog_Data(log, level, ...) | Log a raw data buffer (WLOG_MESSAGE_DATA) |
WLog_Image(log, level, ...) | Log image data (WLOG_MESSAGE_IMAGE) |
WLog_Packet(log, level, ...) | Log a network packet (WLOG_MESSAGE_PACKET) |
WLog_LVL(tag, lvl, ...) | Log at an arbitrary level by tag name |
WLog_VRB(tag, ...) | WLOG_TRACE by tag |
WLog_DBG(tag, ...) | WLOG_DEBUG by tag |
WLog_INFO(tag, ...) | WLOG_INFO by tag |
WLog_WARN(tag, ...) | WLOG_WARN by tag |
WLog_ERR(tag, ...) | WLOG_ERROR by tag |
WLog_FATAL(tag, ...) | WLOG_FATAL by tag |
WLog_Print_tag(tag, level, ...) | Log by tag with explicit level (caches logger internally) |
Context and prefix
Appender management
Layout
Logging code examples
Environment variables
| Variable | Description |
|---|---|
WLOG_LEVEL | Default log level for the root logger. Accepted values: TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF. |
WLOG_FILTER | Comma-separated <logger>:<level> pairs. Only matching loggers are shown. Overrides WLOG_LEVEL for matched loggers. |
WLOG_PREFIX | Format string for the log prefix. See Format specifiers. |
WLOG_APPENDER | Appender type. Accepted values: CONSOLE, FILE, BINARY, SYSLOG, JOURNALD, UDP. |
WLOG_FILEAPPENDER_OUTPUT_FILE_PATH | Directory for the file appender output. |
WLOG_FILEAPPENDER_OUTPUT_FILE_NAME | Filename for the file appender output. |
WLOG_JOURNALD_ID | Identifier used with the systemd journal (defaults to the executable name). |
WLOG_UDP_TARGET | Target for the UDP appender in host:port format (default: 127.0.0.1:20000). |
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.
| Token | Expands to |
|---|---|
%lv | Log level (e.g. INFO, WARN) |
%mn | Module (logger) name |
%fl | Source file name |
%fn | Function name |
%ln | Line number |
%pid | Process ID |
%tid | Thread ID |
%yr | Year |
%mo | Month |
%dw | Day of week |
%hr | Hour |
%mi | Minute |
%se | Second |
%ml | Millisecond |
Appenders
CONSOLE (default)
CONSOLE (default)
Writes to the terminal. On Android, redirects to
Configuration key:
__android_log_print. Output stream routing:outputstream value | Behavior |
|---|---|
stdout | All levels → stdout |
stderr | All levels → stderr |
default | ERROR/FATAL → stderr; others → stdout |
debug | Windows: OutputDebugString; elsewhere: same as default |
outputstream, value: const char*FILE
FILE
Writes formatted text to a file.
| Configuration key | Type | Description |
|---|---|---|
outputfilename | const char* | Output filename |
outputfilepath | const char* | Output directory path |
BINARY
BINARY
Writes log data in a binary format file — useful for post-processing or tooling that parses structured log records.
| Configuration key | Type | Description |
|---|---|---|
outputfilename | const char* | Output filename |
outputfilepath | const char* | Output directory path |
UDP
UDP
Sends log messages over UDP to a remote host. Suitable for centralised log aggregation without writing to disk.
Default target: Receive with netcat:
| Configuration key | Type | Description |
|---|---|---|
target | const char* | Destination in host:port format |
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.| Configuration key | Type | Description |
|---|---|---|
identifier | const char* | Journal identifier (default: winpr) |
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
| Configuration key | Type | Description |
|---|---|---|
callbacks | wLogCallbacks* | Pointer to callback struct |
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.
| Constant | Value | Description |
|---|---|---|
WLOG_MESSAGE_TEXT | 0 | Plain formatted text (use WLog_Print or WLog_PrintTextMessage) |
WLOG_MESSAGE_DATA | 1 | Raw binary buffer (use WLog_Data macro) |
WLOG_MESSAGE_IMAGE | 2 | Image data with width/height/bpp metadata (use WLog_Image macro) |
WLOG_MESSAGE_PACKET | 3 | Network packet with direction flag (use WLog_Packet macro) |
| Constant | Value |
|---|---|
WLOG_PACKET_INBOUND | 1 |
WLOG_PACKET_OUTBOUND | 2 |
wLogMessage structure
All appender callbacks receive a const wLogMessage*. Fields of interest:
