HardySimpson/zlog logo

HardySimpson/zlog

Free

A reliable, high-performance, thread safe, flexsible, clear-model, pure C logging library.

FreeFree tier
Type
Open Source

About HardySimpson/zlog

zlog is a pure C logging library designed for C applications, offering high performance, thread safety, and flexible configuration. It uses a category-format-rule model where log categories, output formats, and rules (mapping categories to output channels and formats) are defined in a configuration file. This decouples log filtering from code, making it more powerful and safer than syslog and printf. Installation is via make and make install, and the library provides a simple API: zlog_init(), zlog_get_category(), and log macros. It aims to fill the gap in the C ecosystem for a robust, Java-logback-like logging solution.

Key Features

Pure C implementation with no external dependencies
High-performance and thread-safe logging
Flexible configuration via categories, formats, and rules
Configuration file-driven, decoupling log filtering from code
Faster and safer than log4c and syslog
Supports output to files, stdout, and other channels with format control
Simple API: zlog_init(), zlog_get_category(), and logging macros
Easy installation via make and make install

Pros & Cons

Pros
  • High performance suitable for production environments
  • Thread safety without sacrificing speed
  • Clear and decoupled configuration model
  • Pure C, no C++ dependency
  • More powerful than traditional syslog and printf
Cons
  • Requires a configuration file for setup
  • Limited ecosystem compared to logging libraries in other languages
  • C-only, not usable directly from C++ without wrapping

Best For

Application logging in C programsReplacing printf for structured loggingReplacing syslog for faster and more flexible loggingBuilding reliable, production-grade C softwareEmbedded systems and performance-critical C applications

FAQ

How do I install zlog?
Download the latest stable release from GitHub, extract the tarball, run 'make' then 'sudo make install'. Optionally set PREFIX for custom installation path.
How do I configure zlog?
Create a configuration file (e.g., /etc/zlog.conf) with [formats] and [rules] sections. Define format patterns and rules that map categories, levels, output files, and formats.
What are categories, formats, and rules?
Categories identify different log entry types in code. Formats define the output pattern (e.g., timestamps, source file, newline). Rules map a category and level to an output channel (file/stdout) and a format.
How do I use zlog in my C code?
Include 'zlog.h', call zlog_init() with the path to your configuration file, get a category handle via zlog_get_category(), then use logging macros to write messages. Example: dzlog_info("my message");