plog is a free, open source monitoring & observability project written in C++ and released under MIT. It has 2,589 GitHub stars, 404 forks and 58 open issues, and was last pushed 1 months ago. On this registry it ranks #130 of 191 tracked projects in Monitoring & Observability, with 5 head-to-head comparisons available.

Plog - portable, simple and extensible C++ logging library

Pretty powerful logging library in about 1000 lines of code CI Build status CircleCI

image

Introduction

Hello log!

Plog is a C++ logging library that is designed to be as simple, small and flexible as possible. It is created as an alternative to existing large libraries and provides some unique features as CSV log format and wide string support.

Here is a minimal hello log sample:

#include <plog/Log.h> // Step1: include the headers
#include "plog/Initializers/RollingFileInitializer.h"

int main()
{
    plog::init(plog::debug, "Hello.txt"); // Step2: initialize the logger

    // Step3: write log messages using a special macro
    // There are several log macros, use the macro you liked the most

    PLOGD << "Hello log!"; // short macro
    PLOG_DEBUG << "Hello log!"; // long macro
    PLOG(plog::debug) << "Hello log!"; // function-style macro
    
    // Also you can use LOG_XXX macro but it may clash with other logging libraries
    LOGD << "Hello log!"; // short macro
    LOG_DEBUG << "Hello log!"; // long macro
    LOG(plog::debug) << "Hello log!"; // function-style macro

    return 0;
}

And its output:

2015-05-18 23:12:43.921 DEBUG [21428] [main@13] Hello log!
2015-05-18 23:12:43.968 DEBUG [21428] [main@14] Hello log!
2015-05-18 23:12:43.968 DEBUG [21428] [main@15] Hello log!

Features

Integration

Plog is a header-only C++ library, making it extremely easy to integrate into any project. You do not need to build or link any binaries — just add the headers to your include path. Here are several recommended ways to add Plog to your project:

Copy the source

Simply copy the plog directory into your source tree. For example:

.                           <-- root of your solution
├── README.md
└── src
    ├── 3rd-party           <-- directory for all 3rd-party dependencies
    │   └── plog            <-- plog is copied there
    │       ├── include     <-- add this to your include search path
    │       │   └── plog
    │       ├── LICENSE
    │       └── README.md
    ├── proj1
    └── proj2

Then, add src/3rd-party/plog/include to your project's include directories.

Git submodule

Add Plog as a git submodule to keep it up to date and track its version:

git submodule add https://github.com/SergiusTheBest/plog.git src/3rd-party/plog
git commit -m "Add plog as a submodule"

This approach allows you to easily update Plog and manage its version. Remember to add src/3rd-party/plog/include to your include path.

CMake integration

add_subdirectory

If you use CMake, you can add Plog directly to your build:

add_subdirectory(3rd-party/plog) # Adds plog to your CMake project

add_executable(myproj main.cpp)
target_link_libraries(myproj plog::plog) # Links and sets include path

FetchContent

Alternatively, use CMake's FetchContent to automatically download Plog at configure time:

include(FetchContent)

FetchContent_Declare(
    plog
    GIT_REPOSITORY https://github.com/SergiusTheBest/plog
    GIT_TAG        1.1.10
    GIT_SHALLOW    true
)
FetchContent_MakeAvailable(plog) # Downloads and adds plog to your CMake project

add_executable(myproj main.cpp)
target_link_libraries(myproj plog::plog) # Links and sets include path

Package managers

Plog is also available via popular C++ package managers:

  • vcpkg
    vcpkg install plog
    
  • Conan
    conan install plog
    
  • NuGet
    nuget install plog
    

Refer to each package manager's documentation for the latest installation instructions and version details.

Usage

To start using plog you need to make 3 simple steps.

Step 1: Adding includes

At first your project needs to know about plog. For that you have to:

  1. Add plog/include to the project include paths
  2. Add #include into your cpp/h files (if you have precompiled headers it is a good place to add this include there)

Step 2: In

readme truncated — read the full docs on github

Frequently asked questions

Is plog free to use?

plog is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does plog do?

Portable, simple and extensible C++ logging library

What is plog written in?

plog is primarily written in C++. Its source is publicly available at https://github.com/SergiusTheBest/plog, and it has 2,589 GitHub stars.