Skip to main content

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 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.
Or using the tag macros (logger is looked up once and cached internally):
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:
WLOG_FILTER enables only the listed loggers at the specified levels. Loggers not matched by the filter are unaffected — they continue to use the level set by WLOG_LEVEL (or their programmatic level).

Format specifiers

The WLOG_PREFIX environment variable (and WLog_Layout_SetPrefixFormat) uses %-prefixed tokens. Up to 16 tokens may appear in a single format string. Example:
This produces lines like:

Appenders

Writes to the terminal. On Android, redirects to __android_log_print. Output stream routing:Configuration key: outputstream, value: const char*
Writes formatted text to a file.
Writes log data in a binary format file — useful for post-processing or tooling that parses structured log records.
Sends log messages over UDP to a remote host. Suitable for centralised log aggregation without writing to disk.Default target: 127.0.0.1:20000.
Receive with netcat:
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).
Sends structured log entries to the systemd journal via sd_journal_send.
View output:
Requires WinPR to be built with WITH_SYSTEMD=ON and libsystemd installed.
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 to WLog_PrintMessage. Packet direction constants:

wLogMessage structure

All appender callbacks receive a const wLogMessage*. Fields of interest: