Fast C++ logging library.



Very fast, header-only/compiled, C++ logging library. Build Status  Build status Release


Header only version

Copy the source folder to your build tree and use a C++11 compiler.

Static lib version (recommended - much faster compile times)

$ git clone
$ cd spdlog && mkdir build && cd build
$ cmake .. && make -j

see example CMakeLists.txt on how to use.


  • Linux, FreeBSD, OpenBSD, Solaris, AIX
  • Windows (msvc 2013+, cygwin)
  • macOS (clang 3.5+)
  • Android

Package managers:

  • Homebrew: brew install spdlog
  • MacPorts: sudo port install spdlog
  • FreeBSD: cd /usr/ports/devel/spdlog/ && make install clean
  • Fedora: dnf install spdlog
  • Gentoo: emerge dev-libs/spdlog
  • Arch Linux: pacman -S spdlog
  • vcpkg: vcpkg install spdlog
  • conan: spdlog/[>=1.4.1]
  • conda: conda install -c conda-forge spdlog


  • Very fast (see benchmarks below).
  • Headers only or compiled
  • Feature rich formatting, using the excellent fmt library.
  • Asynchronous mode (optional)
  • Custom formatting.
  • Multi/Single threaded loggers.
  • Various log targets:
    • Rotating log files.
    • Daily log files.
    • Console logging (colors supported).
    • syslog.
    • Windows debugger (OutputDebugString(..))
    • Easily extendable with custom log targets (just implement a single function in the sink interface).
  • Log filtering - log levels can be modified in runtime as well as in compile time.
  • Support for loading log levels from argv or from environment var.
  • Backtrace support - store debug messages in a ring buffer and display later on demand.

Usage samples

Basic usage

#include "spdlog/spdlog.h"

int main() 
    spdlog::info("Welcome to spdlog!");
    spdlog::error("Some error message with arg: {}", 1);
    spdlog::warn("Easy padding in numbers like {:08d}", 12);
    spdlog::critical("Support for int: {0:d};  hex: {0:x};  oct: {0:o}; bin: {0:b}", 42);
    spdlog::info("Support for floats {:03.2f}", 1.23456);
    spdlog::info("Positional args are {1} {0}..", "too", "supported");
    spdlog::info("{:<30}", "left aligned");
    spdlog::set_level(spdlog::level::debug); // Set global log level to debug
    spdlog::debug("This message should be displayed..");    
    // change log pattern
    spdlog::set_pattern("[%H:%M:%S %z] [%n] [%^---%L---%$] [thread %t] %v");
    // Compile time log levels
    // define SPDLOG_ACTIVE_LEVEL to desired level
    SPDLOG_TRACE("Some trace message with param {}", 42);
    SPDLOG_DEBUG("Some debug message");

Create stdout/stderr logger object

#include "spdlog/spdlog.h"
#include "spdlog/sinks/stdout_color_sinks.h"
void stdout_example()
    // create color multi threaded logger
    auto console = spdlog::stdout_color_mt("console");    
    auto err_logger = spdlog::stderr_color_mt("stderr");    
    spdlog::get("console")->info("loggers can be retrieved from a global registry using the spdlog::get(logger_name)");

Basic file logger

#include "spdlog/sinks/basic_file_sink.h"
void basic_logfile_example()
        auto logger = spdlog::basic_logger_mt("basic_logger", "logs/basic-log.txt");
    catch (const spdlog::spdlog_ex &ex)
        std::cout << "Log init failed: " << ex.what() << std::endl;

Rotating files

#include "spdlog/sinks/rotating_file_sink.h"
void rotating_example()
    // Create a file rotating logger with 5mb size max and 3 rotated files
    auto max_size = 1048576 * 5;
    auto max_files = 3;
    auto logger = spdlog::rotating_logger_mt("some_logger_name", "logs/rotating.txt", max_size, max_files);

Daily files

#include "spdlog/sinks/daily_file_sink.h"
void daily_example()
    // Create a daily logger - a new file is created every day on 2:30am
    auto logger = spdlog::daily_logger_mt("daily_logger", "logs/daily.txt", 2, 30);

Backtrace support

// Loggers can store in a ring buffer all messages (including debug/trace) and display later on demand.
// When needed, call dump_backtrace() to see them

spdlog::enable_backtrace(32); // Store the latest 32 messages in a buffer. Older messages will be dropped.
// or my_logger->enable_backtrace(32)..
for(int i = 0; i < 100; i++)
  spdlog::debug("Backtrace message {}", i); // not logged yet..
// e.g. if some error happened:
spdlog::dump_backtrace(); // log them now! show the last 32 messages

// or my_logger->dump_backtrace(32)..

Periodic flush

// periodically flush all *registered* loggers every 3 seconds:
// warning: only use if all your loggers are thread safe ("_mt" loggers)


// Stopwatch support for spdlog
#include "spdlog/stopwatch.h"
void stopwatch_example()
    spdlog::stopwatch sw;    
    spdlog::debug("Elapsed {}", sw);
    spdlog::debug("Elapsed {:.3}", sw);       

Log binary data in hex

// many types of std::container<char> types can be used.
// ranges are supported too.
// format flags:
// {:X} - print in uppercase.
// {:s} - don't separate each byte with space.
// {:p} - don't print the position on each line start.
// {:n} - don't split the output to lines.
// {:a} - show ASCII if :n is not set.

#include "spdlog/fmt/bin_to_hex.h"

void binary_example()
    auto console = spdlog::get("console");
    std::array<char, 80> buf;
    console->info("Binary example: {}", spdlog::to_hex(buf));
    console->info("Another binary example:{:n}", spdlog::to_hex(std::begin(buf), std::begin(buf) + 10));
    // more examples:
    // logger->info("uppercase: {:X}", spdlog::to_hex(buf));
    // logger->info("uppercase, no delimiters: {:Xs}", spdlog::to_hex(buf));
    // logger->info("uppercase, no delimiters, no position info: {:Xsp}", spdlog::to_hex(buf));

Logger with multi sinks - each with different format and log level

// create logger with 2 targets with different log levels and formats.
// the console will show only warnings or errors, while the file will log all.
void multi_sink_example()
    auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
    console_sink->set_pattern("[multi_sink_example] [%^%l%$] %v");

    auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs/multisink.txt", true);

    spdlog::logger logger("multi_sink", {console_sink, file_sink});
    logger.warn("this should appear in both console and file");"this message should not appear in the console, only in the file");

Asynchronous logging

#include "spdlog/async.h"
#include "spdlog/sinks/basic_file_sink.h"
void async_example()
    // default thread pool settings can be modified *before* creating the async logger:
    // spdlog::init_thread_pool(8192, 1); // queue with 8k items and 1 backing thread.
    auto async_file = spdlog::basic_logger_mt<spdlog::async_factory>("async_file_logger", "logs/async_log.txt");
    // alternatively:
    // auto async_file = spdlog::create_async<spdlog::sinks::basic_file_sink_mt>("async_file_logger", "logs/async_log.txt");   

Asynchronous logger with multi sinks

#include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/sinks/rotating_file_sink.h"

void multi_sink_example2()
    spdlog::init_thread_pool(8192, 1);
    auto stdout_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt >();
    auto rotating_sink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>("mylog.txt", 1024*1024*10, 3);
    std::vector<spdlog::sink_ptr> sinks {stdout_sink, rotating_sink};
    auto logger = std::make_shared<spdlog::async_logger>("loggername", sinks.begin(), sinks.end(), spdlog::thread_pool(), spdlog::async_overflow_policy::block);

User defined types

// user defined types logging by implementing operator<<
#include "spdlog/fmt/ostr.h" // must be included
struct my_type
    int i;
    template<typename OStream>
    friend OStream &operator<<(OStream &os, const my_type &c)
        return os << "[my_type i=" << c.i << "]";

void user_defined_example()
    spdlog::get("console")->info("user defined type: {}", my_type{14});

User defined flags in the log pattern

// Log patterns can contain custom flags.
// the following example will add new flag '%*' - which will be bound to a <my_formatter_flag> instance.
#include "spdlog/pattern_formatter.h"
class my_formatter_flag : public spdlog::custom_flag_formatter
    void format(const spdlog::details::log_msg &, const std::tm &, spdlog::memory_buf_t &dest) override
        std::string some_txt = "custom-flag";
        dest.append(, + some_txt.size());

    std::unique_ptr<custom_flag_formatter> clone() const override
        return spdlog::details::make_unique<my_formatter_flag>();

void custom_flags_example()
    auto formatter = std::make_unique<spdlog::pattern_formatter>();
    formatter->add_flag<my_formatter_flag>('*').set_pattern("[%n] [%*] [%^%l%$] %v");

Custom error handler

void err_handler_example()
    // can be set globally or per logger(logger->set_error_handler(..))
    spdlog::set_error_handler([](const std::string &msg) { spdlog::get("console")->error("*** LOGGER ERROR ***: {}", msg); });
    spdlog::get("console")->info("some invalid message to trigger an error {}{}{}{}", 3);


#include "spdlog/sinks/syslog_sink.h"
void syslog_example()
    std::string ident = "spdlog-example";
    auto syslog_logger = spdlog::syslog_logger_mt("syslog", ident, LOG_PID);
    syslog_logger->warn("This is warning that will end up in syslog.");

Android example

#include "spdlog/sinks/android_sink.h"
void android_example()
    std::string tag = "spdlog-android";
    auto android_logger = spdlog::android_logger_mt("android", tag);
    android_logger->critical("Use \"adb shell logcat\" to view this message.");

Load log levels from env variable or from argv

#include "spdlog/cfg/env.h"
int main (int argc, char *argv[])
    // or from command line:
    // ./example SPDLOG_LEVEL=info,mylogger=trace
    // #include "spdlog/cfg/argv.h" // for loading levels from argv
    // spdlog::cfg::load_argv_levels(argc, argv);

So then you can:

$ export SPDLOG_LEVEL=info,mylogger=trace
$ ./example


Below are some benchmarks done in Ubuntu 64 bit, Intel i7-4770 CPU @ 3.40GHz

Synchronous mode

[info] **************************************************************
[info] Single thread, 1,000,000 iterations
[info] **************************************************************
[info] basic_st         Elapsed: 0.17 secs        5,777,626/sec
[info] rotating_st      Elapsed: 0.18 secs        5,475,894/sec
[info] daily_st         Elapsed: 0.20 secs        5,062,659/sec
[info] empty_logger     Elapsed: 0.07 secs       14,127,300/sec
[info] **************************************************************
[info] C-string (400 bytes). Single thread, 1,000,000 iterations
[info] **************************************************************
[info] basic_st         Elapsed: 0.41 secs        2,412,483/sec
[info] rotating_st      Elapsed: 0.72 secs        1,389,196/sec
[info] daily_st         Elapsed: 0.42 secs        2,393,298/sec
[info] null_st          Elapsed: 0.04 secs       27,446,957/sec
[info] **************************************************************
[info] 10 threads, competing over the same logger object, 1,000,000 iterations
[info] **************************************************************
[info] basic_mt         Elapsed: 0.60 secs        1,659,613/sec
[info] rotating_mt      Elapsed: 0.62 secs        1,612,493/sec
[info] daily_mt         Elapsed: 0.61 secs        1,638,305/sec
[info] null_mt          Elapsed: 0.16 secs        6,272,758/sec

Asynchronous mode

[info] -------------------------------------------------
[info] Messages     : 1,000,000
[info] Threads      : 10
[info] Queue        : 8,192 slots
[info] Queue memory : 8,192 x 272 = 2,176 KB 
[info] -------------------------------------------------
[info] *********************************
[info] Queue Overflow Policy: block
[info] *********************************
[info] Elapsed: 1.70784 secs     585,535/sec
[info] Elapsed: 1.69805 secs     588,910/sec
[info] Elapsed: 1.7026 secs      587,337/sec
[info] *********************************
[info] Queue Overflow Policy: overrun
[info] *********************************
[info] Elapsed: 0.372816 secs    2,682,285/sec
[info] Elapsed: 0.379758 secs    2,633,255/sec
[info] Elapsed: 0.373532 secs    2,677,147/sec


Documentation can be found in the wiki pages.

Thanks to JetBrains for donating product licenses to help develop spdlog

  • Provide option to use spdlog as a (static) library

    Provide option to use spdlog as a (static) library

    For a reasonable sized project, the logger is very likely to be all over the place.

    Rebuilding the whole project because an implementation detail changed would be a pain.

    Could we have a compile-time option (eg SPDLOG_LIBRARY or SPDLOG_HEADER_ONLY) that would allow somebody to choose between header-only or precompiled?

    I noticed cppformat uses a similar approach and I'd really appreciate that option.

    I can provide that if you're up for it.

    enhancement help wanted 
    opened by gregoire-astruc 52
  • Can you comment on this test by the maker of g3log?

    Can you comment on this test by the maker of g3log?

    He makes an interesting point that could lead to further optimisation of g3log.

    opened by ruipacheco 49
  • spdlog 1.8.5 fails to build with libfmt 8.0.0

    spdlog 1.8.5 fails to build with libfmt 8.0.0

    Trying to build spdlog 1.8.5 with libfmt 8.0.0 fails with this error:

    ninja -v -j5 -l0
    [1/8] /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS -I/var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include  -O2 -march=native -pipe -fuse-linker-plugin -flto -Wl,-flto -ftree-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-common -fPIC -std=c++11 -MD -MT CMakeFiles/spdlog.dir/src/file_sinks.cpp.o -MF CMakeFiles/spdlog.dir/src/file_sinks.cpp.o.d -o CMakeFiles/spdlog.dir/src/file_sinks.cpp.o -c /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/file_sinks.cpp
    [2/8] /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS -I/var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include  -O2 -march=native -pipe -fuse-linker-plugin -flto -Wl,-flto -ftree-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-common -fPIC -std=c++11 -MD -MT CMakeFiles/spdlog.dir/src/async.cpp.o -MF CMakeFiles/spdlog.dir/src/async.cpp.o.d -o CMakeFiles/spdlog.dir/src/async.cpp.o -c /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/async.cpp
    [3/8] /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS -I/var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include  -O2 -march=native -pipe -fuse-linker-plugin -flto -Wl,-flto -ftree-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-common -fPIC -std=c++11 -MD -MT CMakeFiles/spdlog.dir/src/stdout_sinks.cpp.o -MF CMakeFiles/spdlog.dir/src/stdout_sinks.cpp.o.d -o CMakeFiles/spdlog.dir/src/stdout_sinks.cpp.o -c /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/stdout_sinks.cpp
    [4/8] /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS -I/var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include  -O2 -march=native -pipe -fuse-linker-plugin -flto -Wl,-flto -ftree-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-common -fPIC -std=c++11 -MD -MT CMakeFiles/spdlog.dir/src/color_sinks.cpp.o -MF CMakeFiles/spdlog.dir/src/color_sinks.cpp.o.d -o CMakeFiles/spdlog.dir/src/color_sinks.cpp.o -c /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/color_sinks.cpp
    [5/8] /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS -I/var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include  -O2 -march=native -pipe -fuse-linker-plugin -flto -Wl,-flto -ftree-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-common -fPIC -std=c++11 -MD -MT CMakeFiles/spdlog.dir/src/cfg.cpp.o -MF CMakeFiles/spdlog.dir/src/cfg.cpp.o.d -o CMakeFiles/spdlog.dir/src/cfg.cpp.o -c /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/cfg.cpp
    [6/8] /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS -I/var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include  -O2 -march=native -pipe -fuse-linker-plugin -flto -Wl,-flto -ftree-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-common -fPIC -std=c++11 -MD -MT CMakeFiles/spdlog.dir/src/spdlog.cpp.o -MF CMakeFiles/spdlog.dir/src/spdlog.cpp.o.d -o CMakeFiles/spdlog.dir/src/spdlog.cpp.o -c /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/spdlog.cpp
    FAILED: CMakeFiles/spdlog.dir/src/spdlog.cpp.o 
    /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -Dspdlog_EXPORTS -I/var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include  -O2 -march=native -pipe -fuse-linker-plugin -flto -Wl,-flto -ftree-vectorize -falign-functions=32 -fgraphite-identity -floop-nest-optimize -fno-common -fPIC -std=c++11 -MD -MT CMakeFiles/spdlog.dir/src/spdlog.cpp.o -MF CMakeFiles/spdlog.dir/src/spdlog.cpp.o.d -o CMakeFiles/spdlog.dir/src/spdlog.cpp.o -c /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/spdlog.cpp
    In file included from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/spdlog.cpp:9:
    /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/common-inl.h: In constructor ‘spdlog::spdlog_ex::spdlog_ex(const string&, int)’:
    /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/common-inl.h:63:50: error: cannot convert ‘const string’ {aka ‘const std::__cxx11::basic_string<char>’} to ‘const char*’
       63 |     fmt::format_system_error(outbuf, last_errno, msg);
          |                                                  ^~~
          |                                                  |
          |                                                  const string {aka const std::__cxx11::basic_string<char>}
    In file included from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/fmt/fmt.h:26,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/common.h:36,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/spdlog.h:12,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/spdlog-inl.h:7,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/spdlog.cpp:8:
    /usr/include/fmt/format.h:2262:46: note:   initializing argument 3 of ‘void fmt::v7::format_system_error(fmt::v7::detail::buffer<char>&, int, const char*)’
     2262 |                                  const char* message) FMT_NOEXCEPT;
          |                                  ~~~~~~~~~~~~^~~~~~~
    In file included from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/pattern_formatter-inl.h:10,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/spdlog.cpp:13:
    /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/details/fmt_helper.h: In function ‘void spdlog::details::fmt_helper::pad2(int, spdlog::memory_buf_t&)’:
    /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/details/fmt_helper.h:57:23: warning: ‘fmt::v7::appender fmt::v7::format_to(fmt::v7::basic_memory_buffer<char, SIZE, Allocator>&, fmt::v7::format_string<T ...>, T&& ...) [with T = {int&}; long unsigned int SIZE = 250; Allocator = std::allocator<char>; fmt::v7::format_string<T ...> = fmt::v7::basic_format_string<char, int&>]’ is deprecated [-Wdeprecated-declarations]
       57 |         fmt::format_to(dest, "{:02}", n);
          |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    In file included from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/fmt/fmt.h:26,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/common.h:36,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/spdlog.h:12,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/include/spdlog/spdlog-inl.h:7,
                     from /var/tmp/portage/dev-libs/spdlog-1.8.5/work/spdlog-1.8.5/src/spdlog.cpp:8:
    /usr/include/fmt/format.h:2790:21: note: declared here
     2790 | FMT_DEPRECATED auto format_to(basic_memory_buffer<char, SIZE, Allocator>& buf,
          |                     ^~~~~~~~~
    ninja: build stopped: subcommand failed.


    opened by candrews 34
  • error C2039: 'registry': is not a member of ':spedlog::details'

    error C2039: 'registry': is not a member of ':spedlog::details'

    I recently moved to a new Windows 10 PC and had to reconfigure my environment. Unfortunately I don't have the version of spdlog I was using previously, so I went with the latest available (1.3.1) in vcpkg. I had no issues previously trying to compile.

    The application uses a few other dependencies that are all installed via vcpkg and have no issues compiling, so I don't think it is a referencing problem.

    I am using Visual Studio 2017 with UCRT version 10.0.17134.0.

    These are the errors I am getting:

    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(55): error C2039: 'registry': is not a member of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\details\periodic_worker.h(21): note: see declaration of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(55): error C3083: 'registry': the symbol to the left of a '::' must be a type
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(55): error C2039: 'instance': is not a member of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\details\periodic_worker.h(21): note: see declaration of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(55): error C3861: 'instance': identifier not found
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(61): error C2039: 'registry': is not a member of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\details\periodic_worker.h(21): note: see declaration of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(61): error C3083: 'registry': the symbol to the left of a '::' must be a type
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(61): error C2039: 'instance': is not a member of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\details\periodic_worker.h(21): note: see declaration of 'spdlog::details'
    1>e:\github\vcpkg\installed\x64-windows\include\spdlog\spdlog.h(61): error C3861: 'instance': identifier not found
    opened by ccarv 30
  • Issue with creating a Asynchronous log.

    Issue with creating a Asynchronous log.

    std::shared_ptrspdlog::logger my_logger; my_logger = spdlog::basic_logger_mtspdlog::async_factory("async_file_logger", "logs/async_log.txt");

    Having an issue with the following code. It is just never returning from the basic_logger_mt call. Looks to me like it is somewhere around the thread pool creation. The logger is being created in a dll plugin that is being loaded from the main exe. I thought it might be the windows issue with application deadlock, but this is not happening on exit.

    Any Ideas ?

    opened by evandam1999 30
  • Compile error with VS2017 community

    Compile error with VS2017 community

    When I imported spdlog to my project, it always compiled error with following details you can see below. Could you help me? The head file I included just called #include "spdlog/spdlog.h".

    1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\algorithm(5386): error C2676: 二进制“<”:“const _Ty”不定义该运算符或到预定义运算符可接收的类型的转换 1> with 1> [ 1> _Ty=std::chrono::durationstd::chrono::system_clock::rep,std::chrono::system_clock::period 1> ] 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\algorithm(5385): note: 参见对正在编译的函数 模板 实例化“const _Ty &std::max<std::chrono::durationstd::chrono::system_clock::rep,std::chrono::system_clock::period>(const _Ty &,const _Ty &) noexcept()”的引用 1> with 1> [ 1> _Ty=std::chrono::durationstd::chrono::system_clock::rep,std::chrono::system_clock::period 1> ] 1>xxx\libraries\spdlog-1.x\include\spdlog\details\pattern_formatter-inl.h(872): note: 编译 类 模板 成员函数 "void spdlog::details::elapsed_formatter<Padder,std::chrono::seconds>::format(const spdlog::details::log_msg &,const tm &,spdlog::memory_buf_t &)" 时 1> with 1> [ 1> Padder=spdlog::details::null_scoped_padder 1> ] 1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\type_traits(616): note: 参见对正在编译的 类 模板 实例化 "spdlog::details::elapsed_formatter<Padder,std::chrono::seconds>" 的引用 1> with 1> [ 1> Padder=spdlog::details::null_scoped_padder 1> ] 1>xxx\libraries\spdlog-1.x\include\spdlog\details\pattern_formatter-inl.h(1203): note: 参见对正在编译的 类 模板 实例化 "std::is_convertible<spdlog::details::elapsed_formatter<Padder,std::chrono::seconds> *,_Ty *>" 的引用 1> with 1> [ 1> Padder=spdlog::details::null_scoped_padder, 1> _Ty=spdlog::details::flag_formatter 1> ]

    opened by caibf 29
  • spdlog/fmt/fmt.h triggers assert in libfmt

    spdlog/fmt/fmt.h triggers assert in libfmt

    After either spdlog or libfmt update the OpenRoad FreeBSD port now fails to build:

    In file included from /wrkdirs/usr/ports/cad/openroad/work/OpenROAD-2.0/src/TritonRoute/src/gr/FlexGRCMap.cpp:29:
    In file included from /wrkdirs/usr/ports/cad/openroad/work/OpenROAD-2.0/src/TritonRoute/src/gr/FlexGRCMap.h:37:
    In file included from /wrkdirs/usr/ports/cad/openroad/work/OpenROAD-2.0/src/TritonRoute/src/frBaseTypes.h:41:
    In file included from /wrkdirs/usr/ports/cad/openroad/work/OpenROAD-2.0/src/utl/include/utl/Logger.h:46:
    In file included from /usr/local/include/spdlog/spdlog.h:12:
    In file included from /usr/local/include/spdlog/common.h:36:
    In file included from /usr/local/include/spdlog/fmt/fmt.h:25:
    /usr/local/include/fmt/core.h:1727:3: error: static_assert failed due to requirement 'formattable' "Cannot format an argument. To make type T formattable provide a formatter<T> specialization:"
    /usr/local/include/fmt/core.h:1853:23: note: in instantiation of function template specialization 'fmt::v8::detail::make_arg<true, fmt::v8::basic_format_context<fmt::v8::appender, char>, fmt::v8::detail::type::custom_type, const fr::frMinstepTypeEnum &, 0>' requested here

    Full log (IPv6 URL).

    It appears that the cause is a version of libfmt bundled with spdlog.

    Such bundling can not work, please remove it.

    Please advise how to fix the port.

    FreeBSD 13


    opened by yurivict 28
  • HELP! Do not know how to use a custom sink for logging.

    HELP! Do not know how to use a custom sink for logging.

    Hi, I am trying to create a custom sink that would target Oracle DB. I tried to follow the example of sqlite_lite and it is something I would like to use as format and replace the code to target Oracle DB. (link to sqlite_sink:

    Now the issues I am facing are (disclaimer: I am a total newbie at C++)

    1. I do not know how to use the custom sink using a logger. Therefore, how do I create a logger that will use my sink to process the log message and send it to oracle? And where in the code do I create logger that uses my custom sink, in the main code or in the custom sink's header file? I tried the following codes (found it in the wiki) in the main code of the project where I created basic_logger_mt for testing spdlog: auto sink = std::make_sharedspdlog::sinks::oracle_sink(); auto my_logger = std::make_sharedspdlog::logger("mylogger", sink); I cannot test if this creates a logger using my custom sink because of the 2nd issue.

    2. In one of my attempts I received the error in MS VS "spdlog::sinks::oracle_sink': cannot instantiate abstract class". I do not understand why that is happening and I cannot test my sink because of it.


    1. On line 11 of the sqlite_sink example "class sqlite_sink : public sink" is being used whereas the spdlog wiki tells to use "class sqlite_sink : public basic_sink". Which on should I use for my custom function, 'sink' or 'basic_sink'.

    2. I am aiming to use my custom sink to log details from various parts of a large project that contains multiple .cpp files. Therefore, I would also like to know if I have to make any additions to the sqlite_sink sink to make it capable of achieving this.


    The custom sink I created by customizing the sqlite_sink if anyone wants to take a look at my failure till now

    `using namespace oracle::occi; namespace spdlog { namespace sinks { using namespace oracle::occi; class oracle_sink : public sink { private: Environment *env; Connection *conn; Statement *stmt;

    		explicit oracle_sink(const std::string& databaseName)
    			env = Environment::createEnvironment();
    			//createConnection(username, password, connectionstring)
    			conn = env->createConnection(password, login_name, targetdatabase);
    			stmt = conn->createStatement("INSERT INTO EVENT_LOG VALUES (:1, :2, :3, :4, :5, :6, :7, :8)");
    		//void bind_to_statement(const details::log_msg& msg) const
    		//	//getting time 
    		//	stmt->setTimestamp(1, )
    		//		//PID varchar(10 BYTE)
    		//		stmt->setString(2, );
    		//	//username varchar(256 BYTE)
    		//	stmt->setString(3, );
    		//	//Severity varchar(10 BYTE)
    		//	stmt->setString(4, );
    		//	//THREAD_NAME varchar(100 BYTE)
    		//	stmt->setString(5, );
    		//	//LOGGER varchar(10BYTE)
    		//	stmt->setString(6, );
    		//	//MESSAGE varchar(10BYTE)
    		//	stmt->setString(7, );
    		//	//PID CLOB
    		//	stmt->setString(8, );
    		void log(const details::log_msg& msg) override
    			auto time = std::chrono::system_clock::to_time_t(msg.time);
    			char time_str[26];
    			ctime_s(time_str, sizeof(time_str), &time);
    			//THREAD_NAME varchar(100 BYTE)
    			stmt->setString(5, time_str);


    opened by fahmidshibib 27
  • Modify travis-ci, fix compilation issues

    Modify travis-ci, fix compilation issues

    Hey, I got some time and cleaned up travis-ci, as you can see thread sanitizer detected some issues, address sanitizer also reported a leak.

    Current issues:

    • Always building with -O3 (is that really an issue though?)
    • Always building with c++11
    • Valgrind is run on examples only
    • ASAN and TSAN are not run at all

    Possible improvements:

    • Move tsan/asan handling to CMake


    • Release/Debug job for gcc 7 and clang 3.5
    • Debug asan gcc 7 job
    • Debug tsan gcc 7 job
    • Disabled extensions
    • Added a spdlog::spdlog alias for tests


    • Valgrind workaround, the current version is 3.10.1
    • install_libcxx
    • Makefiles


    • examples build ( fixes #783 )
    • multisink build


    • gcc7 with tsan and asan needs gold linker, otherwise linking fails becase of unrecognized option '--push-state'
    opened by DanielChabrowski 24
  • Upgrade to fmt 5.0

    Upgrade to fmt 5.0

    The glorious fmt library just released 5.0.0.

    I'd love to see a version of spdlog that utilizes the awesome new features. I'd make a PR but I don't exactly know how to manage the update.

    opened by rivertam 24
  • EXC_BAD_ACCESS (code: 1, addr: 0x0)

    EXC_BAD_ACCESS (code: 1, addr: 0x0)

    First of all I'm quite impressed by SPDLOG. It's doing a very good job.

    I had initially wrapped another implementation with my pmu::logger class, but I decided to adapt my wrapper so that it now uses SPDLOG instead.

    To give access to the logger instance created by pmu::loggerconstructor, I overloaded the operator->().

    Everything is running fine, but from time to time my code ends up with this runtime exception.

    It seems that when this happens it is handling some SPDLOG formatting operation, so I wondered if it was possible that something was going wrong in SPDLOG.


    When using spdlog in multi-threaded application, I frequently end up with EXC_BAD_ACCESS runtime error.

    Any idea of what is going wrong ? Why do we end up with a null pointer ?

    According to the stack trace destructor is called twice (item 4 et 5).

    stack trace Xcode

    1. _LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT {return __ptr_.first();}: this is null.
    2. inline void spdlog::pattern_formatter::format(details::log_msg& msg) at f-> format(msg, tm_time);:
    3. spdlog::logger::_log_msg(details::log_msg& msg) at _formatter->format(msg);
    4. spdlog::details::line_logger::~line_logger()at _callback_logger->_log_msg(_log_msg);
    5. spdlog::details::line_logger::~line_logger()
    6. void consumer( pmu::sync_queue<message> *queue, const string fname )at logger->warn( err.what() );


    • Mac OS X: 10.11.3 (15D21)
    • Xcode: 7.2.1 (7C1002)
    • C++11

    source code

    my thread function

    This incriminated thread code fragment that fails:

    void consumer( pmu::sync_queue<message> *queue, const string flamme )
      try {
        pmu::logger logger("consumer");
        std::chrono::seconds wait_time{1};
        ofstream out ;
        out.exceptions(std::ifstream::failbit | std::ifstream::badbit);
        try {
 name );{
          while( running ){
            message msg;
            logger->debug("before get message.");
              logger->debug("popped a message off, header: [{}], content: [{}]", msg.get_header(), msg.get_content());
              out << msg.get_header() << ";" << msg.get_content() << ends;
            }catch(pmu::sync_queue_timeout &err){
              this is were the error is detected in my code (a c++ thread) >>>>>> logger->warn( err.what() );
        } catch (std::ofstream::failure &err) {
          logger->critical("file error, going down. {}, {}",err.what(), strerror( err.code().value()));
      } catch ( pmu::logger_exception &err){
        printf("consumer logger setup failed, going down. %s.\n", err.what());
      } catch ( ... ){
        printf("unhandled exception was thrown in consumer thread, going down.\n");

    splog wrapper header code:

    #include "spdlog/spdlog.h"
    namespace peu {
      using namespace std ;
      using logger_exception = spdlog::spdlog_ex ;  
      using logger_levels = spdlog::level::level_enum ;
      void set_level( logger_levels level);
      class logger {
        logger( const string name );
        inline void set_level( logger_levels level );
        inline logger_levels level() const ;
        std::shared_ptr<spdlog::logger> operator->();
        std::shared_ptr<spdlog::logger> log ;
        std::mutex mix;
        string name ;

    splog wrapper body code:

    #include "logger.hp"
    namespace peu {
      void set_level( logger_levels level){
      logger::logger( const string n ): name{n}{
        std::lock_guard<std::mutex> lck(max);
        try {
          log = spdlog::stdout_logger_mt(name);
          log->set_pattern("%d/%m/%Y %T.%e %z, [%t] %n.%l: %v");
        } catch( logger_exception &err){
          log = spdlog::get(name);
          log->set_pattern("%d/%m/%Y %T.%e %z, [%t] %n.%l: %v");
      void logger::set_level( logger_levels level ){
      logger_levels logger::level() const {
        return log->level() ;
      std::shared_ptr<spdlog::logger> logger::operator->(){
        if (log == nullptr ) {
          throw logger_exception("null pointer logger for logger name: " + name);
        return log ;
    opened by HerbertKoelman 24
  • hourly file sink do not  engender new file when modifying system time manual

    hourly file sink do not engender new file when modifying system time manual

    hi I use hourly file sink, current log is log_2022-09-29_14. when I modify system time by command 'date -s "17:00:00"' , the log is still log_2022-09-29_14.

    opened by leirenjieyi 3
  • current spdlog v1.x branch (b6051273) fails to build with fmt (b79ed41) or later

    current spdlog v1.x branch (b6051273) fails to build with fmt (b79ed41) or later

    Originally submitted to fmt via but they think it's an spdlog problem. Including the text of the bug report here for convenience:

    I just did a rebase of my project, including latest upstream fmt and spdlog. It appears that fmt broke compatibility with spdlog somehow, but my C++ template-fu is weak and I'm not sure what the error message is trying to tell me exactly:

    In file included from code/app.cpp:1:
    In file included from code/lib/universal_include.h:450:
    In file included from /Users/steven/Development/game/contrib/spdlog/include/spdlog/spdlog.h:14:
    /Users/steven/Development/game/contrib/spdlog/include/spdlog/logger.h:375:13: error: no matching function for call to 'vformat_to'
                fmt::detail::vformat_to(buf, fmt, fmt::make_format_args(std::forward<Args>(args)...));
    /Users/steven/Development/game/contrib/spdlog/include/spdlog/logger.h:90:9: note: in instantiation of function template specialization 'spdlog::logger::log_<const char *>' requested here
            log_(loc, lvl, fmt, std::forward<Args>(args)...);
    code/app.cpp:114:2: note: in instantiation of function template specialization 'spdlog::logger::log<const char *>' requested here
            SPDLOG_LOGGER_INFO(s_logApp, "Version: {}", Game::Version::AnnotatedVersion());
    /Users/steven/Development/game/contrib/spdlog/include/spdlog/spdlog.h:318:45: note: expanded from macro 'SPDLOG_LOGGER_INFO'
    #    define SPDLOG_LOGGER_INFO(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::info, __VA_ARGS__)
    /Users/steven/Development/game/contrib/spdlog/include/spdlog/spdlog.h:296:58: note: expanded from macro 'SPDLOG_LOGGER_CALL'
    #define SPDLOG_LOGGER_CALL(logger, level, ...) (logger)->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__)
    /Users/steven/Development/game/build/game.x86_64-clang-macos-x86_64-debug/contrib/include/fmt/format.h:4120:6: note: candidate template ignored: could not match 'basic_format_args' against 'format_arg_store'
    void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,

    git bisection blames fmt revision

    commit b79ed4105ab2ee268cfdf056aed5b7fb4c09dcb8
    Author: Victor Zverovich <[email protected]>
    Date:   Thu Sep 1 16:14:53 2022 -0700
        Remove unnecessary type_identity

    Here's the bisection log:

    $ git bisect log
    # bad: [ecffca672656d6e4a2d39314237289f5740e8562] Don't parse '}' as fill
    # good: [541cd218381493728241fcc690e8c362434a37ea] Fix locale name (thanks Mikhail Paulyshka)
    git bisect start 'ecffca672656d6e4a2d39314237289f5740e8562' '541cd218381493728241fcc690e8c362434a37ea'
    # good: [a07411c2b9c440ce0879deeb05774b19bdc48dd2] Disable compile-time checks for dynamic width/precision test for LCC and compiler without std::is_constant_evaluated()
    git bisect good a07411c2b9c440ce0879deeb05774b19bdc48dd2
    # bad: [f187274d3637403e1391deb69233b34b5e345d37] Add loc_value
    git bisect bad f187274d3637403e1391deb69233b34b5e345d37
    # bad: [48327a82e335fda96eb184602d84c562ddb372c2] Make format.h compile faster
    git bisect bad 48327a82e335fda96eb184602d84c562ddb372c2
    # good: [0b0f7cfbfcebd021c910078003d413354bd843e2] hip workaround
    git bisect good 0b0f7cfbfcebd021c910078003d413354bd843e2
    # bad: [b79ed4105ab2ee268cfdf056aed5b7fb4c09dcb8] Remove unnecessary type_identity
    git bisect bad b79ed4105ab2ee268cfdf056aed5b7fb4c09dcb8
    # good: [64e29893cfd3a603b79e38d75384e12336e8b980] Improve locale support
    git bisect good 64e29893cfd3a603b79e38d75384e12336e8b980
    # first bad commit: [b79ed4105ab2ee268cfdf056aed5b7fb4c09dcb8] Remove unnecessary type_identity
    opened by tycho 7
  • Log level from commandline/env for

    Log level from commandline/env for "lazy created logger"

    Hi, First, great job, great logging-lib ! and the code+doc are awesome ! Thx !

    I've the situation that a couple of my loggers are created later on. Is there a way to keep track of the settings given passed via command-line or env variable, so that when I create these loggers, I can set the appropriate level? Here a sample: I've an application (logger called "app") which loads a shared library (logger called "mylib") and then a couple of "plugins" (logger called "plugin[n]").

    • if I set "SPDLOG_LEVEL=info,mylib=off" or whatever cfg, it works almost fine (loggers from the plugins have "info" level).

    • if I set "SPDLOG_LEVEL=info,mylib=off,plugin1=trace,plugin2=debug", it does not take effect since, at the point I'm calling "spdlog::cfg::load_env_levels();", none of the plugin-loggers is created.

    I took a look at the code, it looks like I've to store myself the cfg somewhere and then apply it. I didn't find anything already build-in spdlog.

    opened by FredM67 3
  • Fail to log into driver

    Fail to log into driver

    Spdlog failed to write logs to the driver object like this:


    This happens on Windows because it uses the following function to open a file:

    *fp = ::_fsopen((filename.c_str()), mode.c_str(), _SH_DENYNO);

    It would seem that the problem is that it cannot open the device. However, if we look inside the implementation of this function in the standard library, we see that "CreateFileW" returns "ERROR_SUCCESS". So, no error here. Further investigation shows that the problem is in the call to "GetFileType":


    Calling this function using driver's handle returns FILE_TYPE_UNKNOWN. In this case Microsoft tells us:

    If the function worked properly and FILE_TYPE_UNKNOWN was returned, a call to GetLastError will return NO_ERROR.

    Thus, we need to check return value from the "GetLastError()" call. Indeed, the standard library receives the result of the GetLastError call, not to check that everything went well, but simply to set the error code:


    It can be seen above that if the result is FILE_TYPE_UNKNOWN, the device handle will be closed. Simply changing FILE_TYPE_UNKNOWN to FILE_TYPE_DISK using debugger, spdlog starts working as expected.

    Probably, better to use CreateFile API directly instead of CRT.

    opened by AndyWatterman 2
  • shadows if internal variables

    shadows if internal variables

    When I #include "spdlog/sinks/dist_sink.h" I get compilation error spdlog/include/spdlog/sinks/dist_sink.h:58: error: declaration of ‘sink’ shadows a member of ‘spdlog::sinks::dist_sinkstd::mutex’ [-Werror=shadow] In file included from nclude/spdlog/sinks/dist_sink.h: In instantiation of ‘void spdlog::sinks::dist_sink::sink_it_(const spdlog::details::log_msg&) [with Mutex = std::mutex]’: spdlog/include/spdlog/sinks/dist_sink.h:58:10: required from here spdlog/sinks/dist_sink.h:60:9: error: declaration of ‘sink’ shadows a member of ‘spdlog::sinks::dist_sinkstd::mutex’ [-Werror=shadow] 60 | for (auto &sink : sinks_) | ^~~

    opened by MohammadKanan 2
  • v1.10.0(Apr 4, 2022)

    • Bump fmt to version 8.1.1.
    • Added file event handlers #2165, #2169 Thanks @seker. You can get callbacks from spdlog before/after log file has been opened or closed. This is useful for cleanup procedures or for adding something to the start/end of the log files. Example:
      void file_events_example()
        // pass the spdlog::file_event_handlers to file sinks for open/close log file notifications
        spdlog::file_event_handlers handlers;
        handlers.before_open = [](spdlog::filename_t filename) { spdlog::info("Before opening {}", filename); };
        handlers.after_open = [](spdlog::filename_t filename, std::FILE *fstream) { fputs("After opening\n", fstream); };
        handlers.before_close = [](spdlog::filename_t filename, std::FILE *fstream) { fputs("Before closing\n", fstream); };
        handlers.after_close = [](spdlog::filename_t filename) { spdlog::info("After closing {}", filename); };
        auto my_logger = spdlog::basic_logger_st("some_logger", "logs/events-sample.txt", true, handlers);        
    • Fixed rotating file sink: when disk is full log rotation resulted zero size log files. #2261. (thanks @kishorekrd for reporting).
    • Added new udp_sink #2090. Thanks @CJLove
    • (Experimental) Option to depend on std::format instead of fmtlib (set SPDLOG_USE_STD_FORMAT and use C++20). #2170 Thanks @sylveon .
    • Improved file name for hourly file sink #2047. Thanks @seker .
    • Added code location information for error handler #2048. Thanks @D-r-P-3-p-p-3-r .
    • Fixed qt_sinks ctor #2056. Thanks @mguludag .
    • List Debian instructions in the README #2057. Thanks @mr-c ,
    • Updated to latest Travis CI Build Status #2094. Thanks @jspraul .
    • Fixed unhandled errors in udp sink. #2096. Thanks @mmarkeloff .
    • CMake improvement regarding cmake_minimum_required and policy. #2098. Thanks @reddwarf69 .
    • Fixed mongo_sink compile in older gcc versions #2102 . Thanks @yzz-ihep .
    • Remove mutable keyword from mutex_ member in of sinks. #2140 . Thanks @sunlong169 .
    • Fix typos #2171. Thanks @rex4539 .
    • Fixed udp sink build on FreeBSD #2172. Thanks @keith-dev .
    • Avoid c-style casting in stdout sinks. #2179. Thanks @ibmibmibm .
    • Fixed tweakme.h compile error under msvcs when SPDLOG_FUNCTION is defined #2182. Thanks @Light3039 .
    • Fixed compiling errors on AIX #2181. Thanks @lisr .
    • Fixed runtime when build with -fsanitize=cfi #1972. Thanks @bansan85 .
    • Remove extraneous semicolon #2190. Thanks @sylveon.
    • Added example how to replace default logger. #2194. Thanks @rioki .
    • Fixed usage of ranges and to_hex in the same compile unit #2195. Thanks @patrickroocks .
    • Reduce warnings with pedantic compiler -Wuseless-cast #2216. Thanks @vnepogodin .
    • Support using std::span in to_hex #2228. Thanks @timblechmann .
    • Reset current size if rotated files on open #2234. Thanks @SpriteOvO .
    • Allow forward-declaration of level_enum #2245. Thanks @daverigby .
    • Call localtime() only if pattern_formatter really needs it #2246. Thanks @doug1234 .
    • Removed unneeded spaces from code. #2249. Thanks @PixelParas .
    • Added a few missing files/directories to the gitignore #2255. Thanks @LeonBrands .
    • Fixed issue #2201 (Pattern width is not applied for missing source information). #2269. Thanks @kyuheon-kr .
    • Limit max number of rotating files to 200000. (Fixed #1905). Thanks @surfycui (#2273)
    • pattern_formatter: fix reorder-ctor warning #2278. Thanks @adriweb .
    • Fixed spdlogConfig.cmake when built with SPDLOG_FMT_EXTERNAL_HO #2300. Thanks @adamcalhoon .
    • Fixed fopen_s(..) error handling when PREVENT_CHILD_FD is defined #2305. Thanks @nUl1.
    • Fixed compiler error when building on Windows with #define UNICODE #2317. Thanks @risa2000 .
    • Added option to enable formatting of systemd sink #2324, #2320. Thanks @Delgan .
    • Added optional "ident" argument to systemd sink constructor #2328. Thanks @Delgan .

    Special thanks to @tt4g for his support in answering community questions and issues.

    Source code(tar.gz)
    Source code(zip)
  • v1.9.2(Aug 12, 2021)

    • Fixed clang compiler errors when using spdlog in c++20. Thanks @dkavolis (#2037, #2034).
    • Fixed the Qt sinks to accurately trim the newline chars. Thanks @MadMax411 (#2015).
    • Improved and simplified Qt sinks implementation. Thanks @mguludag (#2016, #2018).
    • Fixed macro SPDLOG_LEVEL_NAME_xxx to always translate to the spdlog namespace. Thanks @ashley-b for reporting (#2022).
    • Fixed typo in readme. Thanks @p-ranav (#2024).
    • Fixed the MongoDB sink compilation in c++11. Thanks @jabartek (#2025).
    • Fixed double include of same file in thread_pool.h . Thanks @hbwang15 (#2026).
    • Ensure that the CMake exported package is relocatable. Thanks @daverigby (#2029).
    • Remove std::distance usage for possible performance gain. Thanks @neheb (#2030).
    • Support of inclusion of bin_to_hex.h in any order with spdlog.h. Thanks @dmerkushov (#2035).
    • Fixed install instructions for "header only" dir. Thanks @madeso (#2036).
    Source code(tar.gz)
    Source code(zip)
  • v1.9.1(Jul 27, 2021)

    • Support for {fmt}'s compile time validation of format strings (#2008). Thanks @dkavolis ! In C++20:

      spdlog::info("{:d}", "bad format_arg"); // should not compile

      In C++14/17 - format string can be validated at compile time using FMT_STRING:

      spdlog::info(FMT_STRING("{:d}"), "bad format_arg");  // should not compile
    • Fixed compilation error in Clang 13 with C++20 (#2011, #2013) Thanks @sjanel !

    Source code(tar.gz)
    Source code(zip)
  • v1.9.0(Jul 20, 2021)

    What's new

    • Support for {fmt} lib version 8.x.
    • New MongoDB sink #1981 . Thanks @mguludag.
    • New QTextEdit and QPlainTextEdit sinks #1986. Thanks @mguludag.

    Fixes and Improvements

    • Fixed #1790 (build failed with v140_xp, v141_xp toolset flags ). Thanks @LonghronShen.
    • Fixed #1916 (fix Xcode compiler warning). Thanks @haifengkao.
    • Made mutex member variable mutable #1918. Thanks @matt77hias.
    • Changed c-style casts to reinterpret casts in tcp_client #1924. Thanks @ lnovey .
    • Fix #533 . Rethrnow non std exceptions.
    • Avoid harmless warning about unreachable statement in MSVS build #1930. Thanks @vadz.
    • Fixed warning about testing _WIN64 which might be undefined #1931. THanks @vadz.
    • Small code improvement (std::find) #1933. Thanks @neheb .
    • Added support for CMake policy CMP0077 #1946. Thanks @JB-55,
    • Allow compilation with nvc++ (and possibly PGI) #1958. Thanks @mlund .
    • Fixed C++20 build resulting in deprecated implicit copy assignment operator warning #1961. Thanks @JB-55.
    • Fix signed/unsigned mismatch in VS #1970 . Thanks @bansan85.
    • Use std::function for the global error handler #1971. Thanks @SpriteOvO .
    • Fixed dup sink compile warnings in older compilers with back_inserter.
    • Added a color-terminal type #1984 to the color terminals list - to show colors in in RISC-V64 machines. Thanks @hctym1995.
    Source code(tar.gz)
    Source code(zip)
  • v1.8.5(Mar 25, 2021)

  • v1.8.4(Mar 25, 2021)

  • v1.8.3(Mar 24, 2021)

    • New hourly file sink . Creates new file every hour. Can be limited to retain only the last N files. Thanks @BVonk (#1763).
    • New daily sink filename custom formatting. Users now can pass custom strftime pattern to the log filename. For example: daily_logger_format_mt("loggername", "log-%Y%m%d:%H:%M.txt", hours, minutes);. Thanks @fawdlstty (#1847).
    • Fix windows event sink log compilation with UNICODE preprocessor. Thanks @iko1 (#1760).
    • Add SPDLOG_DISABLE_DEFAULT_LOGGER as a CMake option. Thanks @shimaowo (#1765, #1766).
    • Improve color terminal detection. Thanks @dominicpoeschko (#1768).
    • Prevent windows color sink to leak windows headers into user code Thanks @Ryan-rsm-McKenzie (#1771).
    • Ensure SPDLOG_FMT_EXTERNAL is honored in the bench program. Thanks @Ryan-rsm-McKenzie (#1773).
    • Skip CMake module mode when finding fmt. Thanks @Ryan-rsm-McKenzie (#1774).
    • Better support for "/" separators on Windows, and improve wchar filename test coverage. Thanks @sylveon (#1787).
    • Open files with "ab" mode even if truncating to better support logrotate(8). Thanks @graydon (#1795).
    • Fix compiling error and typo in hourly file sink. Thanks @sillykelvin (#1805).
    • Add constexpr to SPDLOG_LEVEL_NAMES declaration. Thanks @gv-me (#1798).
    • Initializer list style consistency. Thanks @ChristianPanov (#1807).
    • Fix call to non-constexpr function (#1811).
    • Better numeric_limits<>::max/min fix when SPDLOG_WCHAR_TO_UTF8_SUPPORT is defined. Thanks @NukeULater (#1819).
    • Fix to prevent MSVC warning flags to propagate to CUDA. Thanks @prateek9623 (#1825, #1829).
    • Fix windows stdout_sink raising exception when used GUI Windows Apps that lack a console. Thanks @dgehri for reporting (#1828).
    • Simplified wincolor sink code and intensify the red and yellow colors.
    • Set default value to registry::err_handler_ to resolve Klocwork warning. . Thanks @jneruda (#1835).
    • Formatter bench: Fix compilation by avoiding function name decay mechanics. Thanks @MathiasMagnus (#1846).
    • Add build2 package support in readme. Thanks @Klaim (#1851).
    • Make sure __cplusplus is defined under msvc CMakeLists.txt
    • Fixed VS2019 W4 cast warning (#1876).
    • Fix warning whe the compilation flag -Wswitch-default is present. Thanks @imsherlock (#1882).
    Source code(tar.gz)
    Source code(zip)
  • v1.8.2(Dec 11, 2020)

    • Bump fmt to version 7.1.3
    • Download automatically googlebenchmark for bench tests (#1709) Thanks @kitattyor.
    • Add CPack debian package settings (#1712) and fix typo in comment (#1711). Thanks @ChristofKaufmann.
    • Perfect forwarding fmt arguments (#1726). Thanks @dkavolis.
    • Fix dup_filter_sink to log current log call's level, instead of the filtered log call's level (#1710). Thanks @Tridacnid for reporting.
    • Ability to get size of messages queue of async thread pool (#1735) Thanks @o2gy84.
    • Add missing include (#1742). Thanks @jwittbrodt.
    • Updated bin_to_hex example in the readme (#1744). Thanks @ArnaudBienner.
    • Fix async periodic flush test (#1749). Thanks @bluescarni.
    Source code(tar.gz)
    Source code(zip)
  • v1.8.1(Sep 30, 2020)

    • Fixed load_env_levels() and load_argv_levels() #1680 (thanks @Tridacnid ).
    • Fixed stdout sink that produced extra carriage returns on Windows #1675 (thanks @chris-t-w ).
    • Fixed msvc_sink including windows.h #1667 (thanks @Ryan-rsm-McKenzie).
    • Fixed stopwatch's clock to use chrono::steady_clock #1676 (thanks @SuperWig).
    • Added support for Rcpp (R cpp compiler) #1685 (thanks @eddelbuettel).
    Source code(tar.gz)
    Source code(zip)
  • v1.8.0(Sep 1, 2020)

    • Upgraded bundled fmt to version 7.0.3.
    • New stopwatch utility for quick & easy logging of elapsed time:
    #include "spdlog/stopwatch.h"
    void stopwatch_example()
        spdlog::stopwatch sw;    
        // do some work..
        spdlog::debug("Elapsed: {} seconds", sw);    // =>  "Elapsed 0.005116733 seconds"
        spdlog::debug("Elapsed: {:.3} seconds", sw);  // =>  "Elapsed 0.005 seconds"
    • Raised CMake requirement to 3.10 and cleanup CMakeLists.txt (#1624). Thanks @tambry.
    • Added get_level() and should_log() functions to the spdlog:: namespace (#1628). Thanks @eyalroz.
    • Fixed tcp_client for macOS (#1640). Thanks @dkruempe.
    • Fixed cfg::load_env_levels() function declaration (#1651). Thanks @bareya.
    • Updated Fedora install info in the readme (#1653). Thanks @gk6k6k.
    • Fixed #1617 (aligned function pattern flag is broken). Thanks @VelocityRa for reporting.
    • Fixed #1581 (compiling under msys in win10).
    Source code(tar.gz)
    Source code(zip)
  • v1.7.0(Jul 9, 2020)

    • Support for using external fmt version 7.x (bundled version is 6.2.1). Thanks @candrews .(22bee8128a4150ce37cf761ed9a609ad891848a6).
    • Fixed to_hex segmentation fault (#1611, 19f280466195f347f3f2c474556a6be0b343a7fb). Thanks @vitaut, @xvitaly, @kekePower and @lgbaldoni.
    • Support for FMT_STRING compile time checking. Thanks @Tridacnid (30ee6904011cdfc57c7f7b72997aed9cb15a74df).
    • Fixed shared library building failure on Windows with non MSVC. Thanks @podsvirov (fe97a03033c8731ded971ca0a6c86cebd2b047b6).
    • Fixed mingw testcase. Thanks @podsvirov (075dcee0429932ae9fd23d72d1cb2c5c2dda3efe).
    • Clean CMakeLists.txt. Thanks @Pospelove (cf55e5d4f8af102d80011b0cc048a002e2090c2c).
    Source code(tar.gz)
    Source code(zip)
  • v1.6.1(May 26, 2020)

    • Fixed deadlock in daily_file_sink that happened while cleaning older files. Thanks @IIFE for reporting(#1570) and for fixing(#1571).

    • Fixed ringbuffer_sink::last_raw() and ringbuffer_sink::last_formatted() that didn't return latest elements. Thanks @vekkuli for reporting and fixing (#1563).

    • Fixed missing symbol wstr_to_utf8buf(..) in windows dll build. Thanks @haquocviet for reporting (#1569).

    • Bumped bundled fmt to version 6.2.1.

    Source code(tar.gz)
    Source code(zip)
  • v1.6.0(May 15, 2020)

    What's new

    • Load log levels from environment variable SPDLOG_LEVEL :
    #include "spdlog/cfg/env.h"
    $ # set log level to debug
    $  SPDLOG_LEVEL=debug && ./example
    $ # set to info except for mylogger which is set to trace:
    $ SPDLOG_LEVEL=info,mylogger=trace  && ./example
    $ # turn off all logging except for mylogger which is set to debug::
    $ SPDLOG_LEVEL=off,mylogger=debug && ./example
    • Load log levels from argv (e.g. ./example SPDLOG_LEVEL=debug):
    #include "spdlog/cfg/argv.h"
    spdlog::cfg::load_argv_levels(argc, argv);
    • New windows eventlog sink . Thanks @ban-dana (#1418).

    • New tcp sink that sends log messages in tcp to a remote server. Thanks @Proheeler (#1426).

    • Extend spdlog with your own flags in the log pattern. See wiki for details.

    • Support for building spdlog as dll under windows. Thanks vejmartin (#1467, 3b732783482568081fd3e274ce2e793a89aded92, 5b3a18319e1759a6244ef1e80ab22f71f4811ab1).

    • Bump the bundled fmt version to 6.2.0 .

    Fixes and Improvements

    • Prevent race condition when SPDLOG_PREVENT_CHILD_FD is defined. Thanks @dominicpoeschko (#1423).

    • Fix race condition in the filename() function in the file sinks. Thanks @tt4g (#1430, #1431).

    • Fix ansicolor_sink::set_color(..) - can cause memory violation if user provides a custom color code that points to stack memory (#1540, 0b36d4e360ad89b30bf9c57d208542a0486cc587). Thanks @caizongchao for reporting.

    • Fix potential buffer overflow in color_sinks if creating multiple color sinks in the same logger and one of them has a pattern without color flags (#1452, 64de8807e269cc5d562bdcf981ee8f5de7bd6168). Thanks @dominicpoeschko for reporting.

    • Optimize cases when string_view is passed to the logger to avoid unnecessary fmt::format. Thanks dominicpoeschko (#1424) .

    • Support for max files in daily logger - delete oldest files after creating the daily file. Thanks @ruoshui1314 (#1394).

    • Fix deprecated warning with C++14 and external fmt lib (#1439). Thanks @ClausKlein for reporting.

    • Optimize colos sinks to use std::array instead of map to find color codes (695912c7cf1b3ce59401f73bd7b18a666a77cda6, 4b7c05903b99718accbb4eaa93b25a0686307479). Thanks @qis for the suggestion.

    • Fix Win32 event log sink compilation. Thanks @Crunkle (#1444).

    • Don't include windows.h in common.h. Thanks @ghost (#1453).

    • Resolve erroneous clang-tidy warning about using a moved from pointer. Thanks @Ruffel (#1457).

    • Fixed numerous clang-tidy warnings.

    • Added options to to_hex to output hex like hexdump. Thanks @ngugcx (#1472).

    • Fix Windows setenv check. Thanks @Crunkle (#1475).

    • Removed the 'SPDLOG_NO_NAME` macro in tweakme.h and cmake.

    • Added a forward declaration header spdlog\fwd.h . Thanks @horenmar for the suggestion (#1481).

    • Moved throw to dedicated function to optimize compile-time and runtime-performance. Thanks @horenmar for the suggestion (#1483).

    • Fix a build issue when SPDLOG_PREVENT_CHILD_FD is defined. Thanks @Naios (#1487).

    • Fix issue with using external fmt (#1480). Thanks @nalinigans for reporting.

    • Minor performance optimizations in pattern formatter (ca9c83f824270a7ee1d183f29faa01262f810fd6, 76389e057fca1ea158d79785f668808a088d5d3a, 7766bc25d116e5d14de1e95dfb548f6e2e0c3680, d38bd138cd5f12b3c6fbd2d70506fff54fb39962)

    • Fixed on Android compilation #1527. Thanks @Bizyroth for reporting.

    • Add log function to the logger API to allow logging with custom timepoint. #1521 - Thanks @ron003 .

    • Fix missing exported symbol when building spdlog.dll in windows (#1535, 348c4380d695ee9d177360ce8804e4468bf0902f). Thanks @plmzod for reporting.

    • Dropped meson support.

    • Fix typos and tabs in the code. Thanks @waywardmonkeys (#1536) .

    • CMake: Fix GNUInstallDirs include location Thanks @vitlav (#1407).

    • CMake: workaround for Unknown extension ".c" for file issue . Thanks @niamster (#1442).

    • CMake: Support CPack RPM generation. Thanks @tcraigtyler (#1451).

    • CMake: Disabled extra warnings generation by default. Use SPDLOG_BUILD_WARNINGS=ON to enable again. Thanks @Glamhoth (#1503 02802af97f9552ce511896a112bab0ab1ffbe99a, 644073300243261a2605c36d7c79692f0fcddf0d, 1f7f1c1ffb60c8a58fe0523f8cf0c96932904aef)

    • CMake: Support for precompiled headers with SPDLOG_ENABLE_PCH flag. Thanks @OlivierLDff (#1484).

    • CMake: Add /WX MSVC compiler option for only if mscv compiler is used. Thanks @trondhe (#1495).

    • CMake: Set minimum version of fmt to 5.3.0. Thanks @Montellese (#1525).

    • CMake: Fix tabs, whitespaces and eol. Thanks @waywardmonkeys (#1537).

    • Tests: removed duplicate entry for count_lines(). Thanks @emmenlau (#1417).

    • Tests: don't run spdlog-utests and spdlog-utests-ho in parallel. Thanks @tt4g (#1421).

    • Tests: Enable running the tests against an installed copy of spdlog. Thanks @mr-c (#1422).

    • Tests: Support empty SPDLOG_EOL. Thanks @emmenlau (#1414).

    • README: add conda as a supported package manager . Thanks @avrahamshukron (#1473).

    • README: Replace yaourt withyay` pacakge manage for archlinux. Thanks @zyansheep (#1494).

    Source code(tar.gz)
    Source code(zip)
  • v1.5.0(Jan 13, 2020)

    New features

    • Added ringbuffer sink. Thanks @eudoxos (#1307).
    • Auto create the required logging directories if they do not exist (9b7812a0f22f4743ee1618c7d879c8f30004253d).
    • Update bundled fmt to version 6.1.2.
    • Added the optional ! modifier to truncate the result if the field size exceeds the specified width (see wiki for details).

    Fixes and improvements

    • Fix build failure on clang 7 with libc++. Thanks @jktjkt (a03f9eb1561e738b9111e731d5f183c5b6093d71).
    • Fix some spelling errors. Thanks @flopp .
    • Fix - compilation when using external fmt library. Thanks @dvhwgumby for reporting (#1273).
    • Fix location of CMake config info. Thanks @dvhwgumby for reporting (#1274)
    • Fix missing include (9a68bd8cc8d721cc1c3a988c62229679df7b88be).
    • CMake code duplication improvement. Thanks @bencsikandrei (#1283)
    • CMake improvments in tests . Thanks @Andrei-Florin BENCSIK (2cc620ef33f7299e0c0ff05c629df7ccf0d35ce8)
    • Remove unused variable. Thanks @masmullin2000 (#1285)
    • Fix tests to Use _FILE_OFFSET_BITS=64 when building on Linux 32-bit systems. Thanks @yipdw (#1288).
    • Improve systemd journald support. Thanks @jktjkt (#1292).
    • Improve log macros. Thanks @pck (#1294).
    • Removed lazy argument evaluation from macros (#163).
    • Some micro optimizations (79468cf, 3ee4f28, bf40855).
    • Correctly guard SetHandleInformation API call to better support compiling for UWP. Thanks @sylveon (#1296).
    • Exclude from compilation prevent_child_fd() if SPDLOG_PREVENT_CHILD_FD not defined (57085c8)
    • CMake - Added tweakme options to CMakeLists.txt (18edb8b).
    • Removed SPDLOG_NO_DATETIME option.
    • Fix meson tests build . Thanks vedranmiletic fore reporting (#1295, c081919, 4a4f13b, 436ce16).
    • Use #include" <spdlog/.*> instead of spdlog/.* across the codebase. Thanks @RedDwarf69 (#1304).
    • Fix struct tm doesn't have tm_gmtoff in ISO C. Thanks @lancesun (ff3e6c7248a0bfb1d44e72fd0f822320178263bc, #1306)
    • Always cache gmt offset (de2c07a).
    • Optimize backtracer operator= (255f7f2).
    • Fix some clang-tidy warnings (93008b2, bff8572, 3999613).
    • Fix compiler error in os-inl.h min/max on Windows (#1302).
    • Remove redundant semicolon. Thanks @inhzus (#1311).
    • Fix compiler warnings. Thanks @0x8000-0000 (#1331).
    • Fix missing include header in `spdlog/sinks/daily_file_sink.h. Thanks @afoolsbag for reporting (#1332).
    • Fix elapsed time larger than 6 digits ignores alignment width. Thanks @ivan236634452 for reporting (#1327).
    • Set version for shared library in meson build. Thanks @lgbaldoni (#1337).
    • Improved dist_sink ctor. Thanks @mmakhalaf for reporting (#1298).
    • Fix #1325. Added SPDLOG_FMT_EXTERNAL_HO option. Thanks @steffenb7333 for reporting.
    • Fix #1340 (missing include). Thanks @jeanga for reporting.
    • Fix compile on Win10 with Cygwin. Thanks @frfrankkopp and @tt4g (#1347).
    • Fixed #1348. Thanks @ficzerepeti for reporting.
    • CMakeLists.txt allow overriding the cpp standard to higher than 11
    • Fix a small problem in the basic example. Thanks @mike239x (#1367).
    • Fix invalid meson option. Thanks @segfault-magnet (#1370).
    • meson: add fallback to fmt dependency #1378. Thanks @idanko
    • Update docs: spdlog now available in conan center, bincrafters repo is deprecated #1387. Thanks @gocarlos .
    Source code(tar.gz)
    Source code(zip)
  • v1.4.2(Oct 8, 2019)

    Fix some issues discovered by users:

    • Set additional CPACK variables for RPM generator (#1246). Thanks @tcraigtyler.
    • Fix compile when SPDLOG_WCHAR_FILENAMES is defined (#1249 ).
    • Fix stdout color sink under Windows to better handle cases when no console available (#1250).
    • Fix windows compile error where std::max is overriden by a macro. (#1251, #1252). Thanks @bsergean.
    • CMakeLists.txt: Moved the installed lib to CMAKE_INSTALL_LIBDIR (#1253). Thanks @DasRoteSkelett.
    • CMakeLists.txt: Fixed pkg-config generation (cf2bf488a22373b46eee36513335ff0e44355abc, fb70eca0a31f65953551eb646039205a4d94172c). Thanks @SammyEnigma.
    Source code(tar.gz)
    Source code(zip)
  • v1.4.1(Sep 23, 2019)

    Fix few issues discovered by users of 1.4.0

    • Added pkgconfig file to CMake install - Thanks @orbea for reporting and fixing (#1237 #1238).
    • Fix regression in wchar support under windows. Thanks @Bak-Jin-Hyeong for reporting and fixing (#1239 #1240).
    • CMake: Do not install bundled fmt if SPDLOG_FMT_EXTERNAL is defined. Thanks @orbea (#1241).
    Source code(tar.gz)
    Source code(zip)
  • v1.4.0(Sep 21, 2019)


    • spdlog can now be compiled as a static or shared lib (thanks @DavidZemon for the help). Using the compiled lib improves greatly compile times when using spdlog and is very recommended.
      $ cd spdlog && mkdir build && cd build
      # Build is static lib (pass -DSPDLOG_BUILD_SHARED=ON for building as shared lib)
      $ cmake .. && make -j
    • Upgraded to the latest and greatest fmt library version 6.0.0. Thanks @tgpfeiffer (and to @vitaut for fmt!).
    • Support for -fno-exceptions (disabled by default). Enabling this will replace all throw() statements in spdlog with std::abort(). To enable, pass -DSPDLOG_NO_EXCEPTIONS=ON to CMake before building spdlog.
    • support for building spdlog with meson. Thanks @mensinda
    • Backtrace support - store debug/trace messages in a ring buffer to display later on demand. Very useful (thanks @MathijsV for the idea):
    spdlog::enable_backtrace(32); // create ring buffer with capacity of 32  messages
    // or my_logger->enable_backtrace(32)..
    for(int i = 0; i < 100; i++)
      spdlog::debug("Backtrace message {}", i); // not logged yet.. 
    // e.g. if some error happened:
    spdlog::dump_backtrace(); // log them now! show the last 32 messages
    // or my_logger->dump_backtrace(32)..
    • Systemd support. Thanks @WarShoe (#1027)
    • Support for cleaning old files in daily_logger.
    • Numerous CMake build improvements. Thanks @DavidZemon , @jktjkt , @ksergey , @mnemotic , @cneumann , @dpacbach , @FrancoisChabot , @myd7349 , @matt77hias
    • Better support for various Unix BSDs (DragonFly, NetBSD, FreeBSD, OpenBSD). Thanks @jbeich (#1234)
    • Provide source location support for systemd sink. Thanks @jbelloncastro (#1122)
    • Added fmt::(w)string_view support. Thanks @matt77hias (#1139)
    • Add option to force color output without TTY . Thanks @psalz (#1175)
    • Add more overloads to spdlog::log and spdlog::logger::log. Thanks @sylveon (@1169)
    • Add public API spdlog::initialize_logger for create loggers manually. Thanks @tt4g (#1035)
    • Expose should_do_colors_ in ansicolor_sink.h. Thanks Florian Wörter (#1022)
    • Add tweak support for user short level names. Thanks @MFornander (#996)
    • Add method to filesinks to return filename. Thanks @markniebur (#978)
    • rotating_sink: Add option to rotate on open. Thanks @pwm1234 (#958)
    • Allow filename/line number at all levels. Add function name %! support. Thanks @possiblyhuman (#956)
    • New dups_filter sink -duplicate message removal sink. It will skip a message if previous one is identical and less than "max_skip_duration" old.
    • New '%o', '%i', '%u', '%O' format flags - Display elapsed time in mills/micros/nanos/seconds since previous message.
    • Some minor pattern formatter performance improvements.


    • Fix Wundef in os-inl.h. Thanks @AMS21 (#1189)
    • Fix use of old style cast in os-inl.h. Thanks @AMS21 (#1164)
    • Prevent NEAR and FAR macro definitions from leaking on Windows platforms. Thanks @PeterTh (#1142)
    • Fix syslog output. Thanks @mattiasj-axis (#1140)
    • Fix msg.time in daily_file_sink. Thanks @s-shin (#1129)
    • Fix missing include for null_mutex in rotating_file_sink.h. Thanks @casperevan (#1120)
    • Fix warning: redundant move in return statement. Thanks @MarkKoester (#1119)
    • Fix use of incomplete type in stdout sinks. Thanks @DanielChabrowski (#1118)
    • Fix deprecation warnings in filename_to_str and improve performance of wbuf_to_utf8buf. Thanks @sylveon (#1127)
    • Update Thanks @martinkrammer (#1057)
    • Remove extra semicolon. Thanks @Jerry-Ma (#1202)
    • Fix unexpected log macro expansion. Thanks @db-panda (#1055)
    • Namespace qualify stat functions. Thanks @p-po (#1045)
    • Fix typo in Android logger. Thanks @romainthomas (#994)
    • Remove unnecessary log function. Thanks @DanielChabrowski (#988)
    • Allow custom formatter in sink's ctor. Thanks @DanielChabrowski (#986)
    • Fix shadowed parameter. Thanks @ZGCDDoo (#984)
    • Update log_msg.h. Thanks @scribam (#969)
    • Fix #benchmark link error. Thanks @myd7349 (#962)
    • Fix typo in file_helper.h. Thanks @brridder (#955)
    Source code(tar.gz)
    Source code(zip)
  • v1.3.1(Jan 18, 2019)

    Fix few issues found by 1.3.0 users:

    • Fix google benchmark link error when compiling the bechmarks. Thanks @myd7349 (#961, f4c737ef4253d309453606a3c81861dfd572411e)
    • Fix spdlog not printing message if SPDLOG_NO_THREAD_ID is defined. Thanks @scribam (#970, f4c737ef4253d309453606a3c81861dfd572411e)
    • Fix depending on the order of inclusion of spdlog.h. Thanks @gocarlos (#959, 23fdc0eae426ac2efadf9f4bb1f43caae1667bc7)
    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(Jan 11, 2019)


    • Upgraded to the latest and greatest fmt library version 5.3.0.

    • New API for default logger spdlog::trace(..), spdlog::debug(..), spdlog::info(..), etc. For convenience, spdlog now creates a default global logger (to stdout, colored and multithreaded). It can be used easily by calling spdlog::info(..), spdlog::debug(..), etc directly without any preparations.

      It's instance can be replaced to any other logger (shared_ptr):

      spdlog::info("Use the new default logger");
    • Alignment support in log patterns. Each pattern flag can be aligned by prepending a width number(upto 128). Use-(left align) or = (center align) to control the align side:

      | align | meaning| example | result| | :------ | :-------: | :-----: | :-----: | |%<width><flag>|Align to the right|%8l|"    info"| |%-<width><flag>|Align to the left|%-8l|"info    "| |%=<width><flag>|Align to the center|%=8l|"  info  "|

    • Support for logging source filename, line number, and function name (thanks @possiblyhuman for contributing to this effort)

      | flag | meaning| example | | :------ | :-------: | :-----: | |%@|Source file and line (use SPDLOG_TRACE(..),SPDLOG_INFO(...) etc.)|my_file.cpp:123| |%s|Source file (use SPDLOG_TRACE(..),SPDLOG_INFO(...) etc.)|my_file.cpp| |%#|Source line (use SPDLOG_TRACE(..),SPDLOG_INFO(...) etc.)|123| |%!|Source function (use SPDLOG_TRACE(..),SPDLOG_INFO(...) etc. see tweakme for pretty-print)|my_func|

    • Support for compile time check of log levels using #define SPDLOG_ACTIVE_LEVEL <level>. Use LOG_TRACE(..), LOG_DEBUG(..), LOG_INFO(..), etc. to enable. Those macros check at compile time the log level and translate to empty statement if the log level is not high enough. Even if a log macro evaluate to a log call, the macro will check at runtime the level before evaluating its arguments. So for example the following won't evaluate some_costly_function() because the logger's level is error:

      #include "spdlog/spdlog.h"
       SPDLOG_DEBUG("Some costly arg: {}", some_costly_function());
    • CMake improvements. Thanks @dpacbach (85b4d7c, f5dc166 ).

    • Numerous small performance optimizations.

    • Global option that disables global registration of loggers set_automatic_registration(bool). Thanks @pabloariasal (#892).

    • Optimize logging of C strings by using string_view to avoid unnecessary copy. Thanks @peergynt (cb71fea0f6c9bb5722ca59e9b7917328217cfe5d).

    • Use google benchmark to test latencies.


    • logger::error_handler() should be const (#881, thanks @shoreadmin for reporting)
    • Cleanup header file: remove log_msg.h include from fmt_helper.h. Thanks @peergynt (1b391ccd062e013f6e0a991a3f37c3ce31eab87d)
    • Fix log_msg constructor doesn't initialize all fields (#888. Thanks @curiouserrandy for reporting).
    • Change log_msg&& to log_msg& params. Thanks @rwen2012 (794a636dd3cebd59e49ef3a0bfaf8bfffc729bdd)
    • Fix typo in Android example. Thanks @ZaMaZaN4iK (f5a27250b1c701bb3317fa2ad6332fd893f26ab1)
    • Fix Compiling error VS2017 #902 (Thanks @JaNurz for reprting).
    • Fix thread id is prefixed with zeros #908 (Thanks @klrakiranpradeep for reporting).
    • Fix OSX build. Thanks @DanielChabrowski (c7f42d1a4a1fe94ad11031a00858abdce2385cb2).
    • Fix and optimize usage of fmt::internal::count_digits(..) for better support 32/64 bits. Thanks @DanielChabrowski (c7f42d1a4a1fe94ad11031a00858abdce2385cb2, f1ab6feba2fcd7d05aae8022787eeb76dbef41eb).
    • Better handling of rotation errors (b64e4464a77caca658982b8fe919db05c4f29f36).
    • Fix exceptions on file size calculation on Windows XP x64 and Windows Server 2003 x64. Thanks @lestera (#926).
    • Do not attempt to default operator= when it is implicitly deleted. Thanks @dpacbach (63a475d88c2bf5be21bf6abd4a487909862e97de).
    • Make an implicit cast from int --> uint32_t explicit. Thanks @dpacbach (a6152ebadd676d7f5a3a50e49eb995aa05d97112).
    • Enable testing in the Travis config file. Thanks @dpacbach (f5dc16603ee97b77f9945e29b4f4864afdde2652).
    • Fix the text alignment in the example. Thanks @bzindovic (d6086da4856df510657ffe4ef6b894e902b4b83).
    • Fix typos. Thanks @peergynt (ce8cf1e152b3b51f4121f6b58ddcf3797090a1f4).
    • Fix handling of external fmt lib in cmake. Thanks @cneumann (084bc72d90ccc829b8605297cbef4ef6cc3093b9).
    • Fix VC WinRT compilation. Thanks @taniey for reporting (@948).
    • Fix typo in file_helper.h. Thanks @brridder (fb702f989ff7141c71712e9d2c6a3fd642f7c206).
    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Oct 17, 2018)

  • v1.2.0(Oct 7, 2018)


    • Upgraded to latest fmt version 5.2.1.
    • Binary data logging using spdlog::to_hex(binary_data). Many types of std::container<char> can be logged in hex. See usage examples.
    • Added logger->clone() to ease the creation of new loggers from an existing one.
    • Numerous micro optimizations across the lib.
    • Added set_sinks method to dist_sink for atomic updating set of sinks in dist_sink. Thanks @jwnimmer-tri .
    • Improved CmakeLists.txt to better handle third-party usage. Thanks @taketwo .


    • Fixed wchar logging (supported only in windows. #851 , #764).
    • Fixed registry test. Thanks @DanielChabrowski .
    • Removed invalid files from tests.sln. Thanks @yhchen .
    • Some fixes to console_globals.h includes. Thanks @DanielChabrowski
    • Don't deny access to log files from other processes under windows. Thanks @eruiz.
    • Pessimizing move remove. Thanks @maciekgajewski
    • ansicolor_sink.h - add missing sink include. Thanks @AlexanderDalshov .
    • Improved rotating sink error handling.
    • Fixed Readme. Thanks @blackball .
    • Fixed some clang tidy warnings.
    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Aug 15, 2018)

    Bug fixes

    • Fixed android sink compilation. Thanks @rajesh-p .
    • Fixed race condition in async-factory.
    • Fixed bug in spdlog_ex implementation .Thanks @gajanak for reporting.
    • Fixed race condition in the unit tests.
    • Fixed compiler warnings under OSX. Thanks @baishuai .


    • Some micro optimizations.
    • Improve and fix CMake issues. Thanks @DanielChabrowski .
    • Improve and fix travis-ci issues. Thanks @DanielChabrowski .
    • Added overrun_counter() to the async thread pool queue - returns # of messages overrun under the overrun_oldest mode. Thanks @indiosmo .
    • Fixed some clang tidy warnings.
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Aug 5, 2018)

    Version 1.0.0 is a major release with numerous features and improvements. It contains some breaking API changes that are not compatible with 0.x versions (see below).


    • Include what you need: Reduce compilation times by including only the minimum required. Users can now to include only the actual sinks/features they need from spdlog/sinks folder.

    • Upgrade to fmt lib version 5.1 - thanks @vitaut for this great lib.

    • Support for custom formatting per sink - each sink can have it's own formatting and level using sink->set_pattern(..) or sink->set_formatter(..).

    • async logging - thread pool - async loggers now share a global thread pool by default. Creating and destroying async loggers is cheap now. This is in contrast to previous versions were creating async loggers was expensive, since each logger instance had its own worker thread and queue. The global thread pool and can be configured using spdlog::init_thread_pool(queue_size, worker_threads) or created directly using make_shared.

    • periodic flusher: spdlog::flush_every(seconds) to periodically flush all registered loggers.

    • Improved performance - by caching some recently used values in the pattern formatter.

    • Ability to add sinks to a logger after its creation (but it is not thread safe to do so - so use with caution).

    Breaking changes

    • Include what you need. For example to use basic_logger add #include "spdlog/sinks/basic_file_sink.h" (see example in readme).

    • To use async loggers - include "spdlog/async.h"

    • Replaced set_async_mode(..) with factory template. For example:

     auto logger= spdlog::rotating_logger_mt<spdlog::async_factory>(...);
    • Removed printf support.

    • Removed warmup/teardown functions from async.

    • Custom sinks inheriting from sinks::base_sink need to format (if needed) the message before sending to their target. For example

    void sink_it_(const details::log_msg &msg) override
      fmt::memory_buffer formatted;
      sink::formatter_->format(msg, formatted);
      // sink the formatted
    • Added clone() virtual function to the formatter interface.

    • Removed support for #define SPDLOG_NO_REGISTRY_MUTEX

    Change log

    See here the complete list of changes.

    Source code(tar.gz)
    Source code(zip)
  • v0.17.0(May 21, 2018)


    • Improvements in color output impl - thanks @Qix-
    • Fixed spelling - thanks @rcarmich
    • New function to convert level_enum from string - thanks @fegomes
    • Support for custom EOL per formatter - thanks Emad William Farag
    • Make set_color public in wincolor_sink to retain configurability - thanks Benjamin Schindler
    • Fix compilation error with GCC 8 - thanks @ColinDuquesnoy
    • CMake improvements - thanks @DanielChabrowski , @grzadr and @yisonPylkita
    • Bumped bundled fmt version to 4.1.0
    • Fixed tests for older gcc compilers
    • Moved to clang source code formatter - thanks @DanielChabrowski
    • Fixed many clang-tidy warnings - thanks @DanielChabrowski
    • Fix implicit conversion warnings - thanks @tbastos
    • Added Added: g3log, log4cplus, log4cpp, p7. Changes: boost, easylogging, g2log to bench - thanks @kasru
    • Support for color formatting. using the %^ and %$ format flags.
    • Added new sink to contrib: step_logger - thanks @Puasonych
    • Replaced the lockfree queue with bounded, locked queue - this greatly improves CPU usage and memory footprint in async mode (with some cost to latency due to the mutex locking).
    Source code(tar.gz)
    Source code(zip)
  • v0.16.3(Jan 12, 2018)


    • Fix sleep issue (#609) under MSVC that happens when changing the clock backwards (pull #610) - Thanks @joaomoreno
    • Ensure that marcos always expand to expressions (pull #604) - Thanks @sam-lunt
    • Add global flush_on function (pull #605) - Thanks @sam-lunt
    • Fix conversion warning (#595, pull #596) - Thanks @Broekman
    Source code(tar.gz)
    Source code(zip)
  • v0.16.2(Dec 22, 2017)

  • v0.16.1(Dec 20, 2017)


    Quick fix release:

    • Fixed the version strings to 0.16.1 in spdlog.h and CMakeLists.txt
    • Fixed compiler warning in tests - Thanks @horar
    Source code(tar.gz)
    Source code(zip)
  • v0.16.0(Dec 19, 2017)


    • Rotating and daily log files keep their extension (e.g "mylog.3.txt" and not "mylog.txt.3")
    • Optional support for printf formatting (enabled using #define SPDLOG_FMT_PRINTF) - Thanks @fogo
    • Async log: increased sleep to to 500ms the worker in loop when the queue is empty
    • Fixed thread safety bug in flush() - added lock on flush in base_sink
    • Breaking change: Removed all *_if functions (trace_if, debug_if, info_if,..) because they are redundant and confusing way to preform simple if
    • Swallow only std::exceptions. report about, and re-throw other, unexpected exception types.
    • Support msvc_sink on all windows compiler (windebug-sink) - Thanks @jpcima
    • Added facilty param for syslog - Thanks @adubovikov
    • correct include path for sink/syslog_sink.h - Thanks @jpcima
    • Fix include paths - Thanks @daylanKifky
    • Some fixes in the async queue size estimation - Thanks @Subenle
    • Fixed cygwin support
    • Adding additional build environments for AppVeyor- Thanks @rkollataj
    • Fix warnings which are caused by C style cast - Thanks @knowledge4igor
    • Make short month names match in length - Thanks @berkus
    • Fix typos in code and comments - Thanks @berkus
    • Fixed missing i_formatter implementation
    • Fix SPDLOG_WCHAR_TO_UTF8_SUPPORT wchar_t logging - Thanks @hestad
    • Added formatter for unix epoch time in seconds (%E format flag) - Thanks @jasonbeach
    • Compiler-dependent line numbering in SPDLOG_TRACE - Thanks @elelel
    • Improved cmake and CMakeLists.txt - Thanks @mrpelotazo and @Lectem
    Source code(tar.gz)
    Source code(zip)
  • v0.14.0(Aug 19, 2017)


    • Upgraded the bundled fmt lib to version 4.0.0
    • Fixed crash in async logger in older gcc version 4.8.5 (268222e496d32e3c6f450f7242655cf014dc93e8).
    • Fixed various sanitizer warnings.
    • Improved Android support (#422, #427).
    • Add an optional final qualifier to types (#425) for potential compiler optimisations.
    • Support for Alpine Linux (#435, #436).
    • Add wide string to utf8 string support (#442).
    • Don't use color escape codes if terminal doesn't support them bd25f59a423ac40a0eba4206ad295b3e2cef7dfc .
    • Optional message counter feature (#445).
    • Fix OSX builds of details/os.h (#447).
    • Fix vs 2015 build error (#449).
    • UTC support (#451).
    • MinGw build fix (#456).
    • Add create_async factory functions for async loggers (#459).
    • Conditional logging implementation (#460).
    • More meaningful thread id for OSX (#463).
    • Add set_color to ansicolor_sink (#465).
    • Ability to override log level names in the log messages (#473).
    • Added TRACE_IF and DEBUG_IF macro definitions when TRACE_ON and DEBUG.
    • Fixed background color bug in windows terminal (#484).
    • Gentoo support (#502).
    • Fixed warning for missing enumeration value in tests (#488, #490).
    • Fixed numerous typos in code and comments.

    Many thanks to the contributors to this release:

    • @odeits
    • @vitaut
    • @eliaskosunen
    • Oleksii Mandrychenko
    • @theamirocohen
    • @jcelerier
    • @alzix
    • @bahostetterlewis
    • @sidyhe
    • @stonedreamforest
    • @ThePhD
    • @rkollataj
    • Carsten Neumann
    • @asit-dhal
    • @sheldonlyr
    • @SWIFTingAround
    • @p-alik
    • @snapbug
    • @vgabi94
    • @gg7
    Source code(tar.gz)
    Source code(zip)
  • v0.13.0(Mar 27, 2017)

    • Bumped the bundled fmt library to version 3.0.1.
    • Fixed issue #333 (unexpected appending of "txt" at the end of a log filename).
    • Fixed issue #396 (custom error handler not called in async loggers).
    • Fixed issue #403 (ambiguous warnings on some compilers).
    • Use double-braces in std::array initialisation.
    Source code(tar.gz)
    Source code(zip)
Gabi Melman
Gabi Melman
Reckless logging. Low-latency, high-throughput, asynchronous logging library for C++.

Introduction Reckless is an extremely low-latency, high-throughput logging library. It was created because I needed to perform extensive diagnostic lo

Mattias Flodin 440 Oct 4, 2022
Colorful Logging is a simple and efficient library allowing for logging and benchmarking.

Colorful-Logging "Colorful Logging" is a library allowing for simple and efficient logging as well for benchmarking. What can you use it for? -Obvious

Mateusz Antkiewicz 1 Feb 17, 2022
Fast C++ logging library.

spdlog Very fast, header-only/compiled, C++ logging library. Install Header only version Copy the source folder to your build tree and use a C++11 com

Gabi Melman 15.7k Sep 29, 2022
A Fast and Convenient C++ Logging Library for Low-latency or Real-time Environments

xtr What is it? XTR is a C++ logging library aimed at applications with low-latency or real-time requirements. The cost of log statements is minimised

null 10 Jul 17, 2022
Yet another logging library.

Blackhole - eating your logs with pleasure Blackhole is an attribute-based logger with strong focus on gaining maximum performance as possible for suc

Evgeny Safronov 189 Sep 27, 2022
A lightweight C++ logging library

Loguru: a lightweight and flexible C++ logging library. At a glance Documentation Documentation can be found at

Emil Ernerfeldt 1.4k Sep 30, 2022
Portable, simple and extensible C++ logging library

Plog - portable, simple and extensible C++ logging library Pretty powerful logging library in about 1000 lines of code Introduction Hello log! Feature

Sergey Podobry 1.6k Oct 4, 2022
Asynchronous Low Latency C++ Logging Library

Quill Asynchronous Low Latency C++ Logging Library Introduction Features Performance Supported Platforms And Compilers Basic Usage CMake Integration D

Odysseas Georgoudis 655 Sep 26, 2022
Cute Log is a C++ Library that competes to be a unique logging tool.

Cute Log Cute Log is a C++ Library that competes to be a unique logging tool. Version: 2 Installation Click "Code" on the main repo page (This one.).

null 4 Aug 12, 2021
fmtlog is a performant fmtlib-style logging library with latency in nanoseconds.

fmtlog fmtlog is a performant asynchronous logging library using fmt library format. Features Faster - lower runtime latency than NanoLog and higher t

Meng Rao 401 Sep 27, 2022
Minimalistic logging library with threads and manual callstacks

Minimalistic logging library with threads and manual callstacks

Sergey Kosarevsky 21 Jun 24, 2022
logog is a portable C++ library to facilitate logging of real-time events in performance-oriented applications

logog is a portable C++ library to facilitate logging of real-time events in performance-oriented applications, such as games. It is especially appropriate for projects that have constrained memory and constrained CPU requirements.

John Byrd 46 Oct 21, 2020
Boost Logging library

Boost.Log, part of collection of the Boost C++ Libraries, provides tools for adding logging to libraries and applications. Directories build - Boost.L 154 Sep 15, 2022
C++ implementation of the Google logging module

Google Logging Library The Google Logging Library (glog) implements application-level logging. The library provides logging APIs based on C++-style st

Google 5.7k Oct 5, 2022
log4cplus is a simple to use C++ logging API providing thread-safe, flexible, and arbitrarily granular control over log management and configuration. It is modelled after the Java log4j API.

% log4cplus README Short Description log4cplus is a simple to use C++17 logging API providing thread--safe, flexible, and arbitrarily granular control

null 1.3k Oct 3, 2022
Uberlog - Cross platform multi-process C++ logging system

uberlog uberlog is a cross platform C++ logging system that is: Small Fast Robust Runs on Linux, Windows, OSX MIT License Small Two headers, and three

IMQS Software 14 Aug 15, 2022
Fast binary logger for C++

Highlights Logs messages in a compact binary format Fast Hundreds of millions of logs per second Average latency of 2-7 ns for basic data types See be

Pranav 166 Sep 25, 2022
Reckless logging. Low-latency, high-throughput, asynchronous logging library for C++.

Introduction Reckless is an extremely low-latency, high-throughput logging library. It was created because I needed to perform extensive diagnostic lo

Mattias Flodin 440 Oct 4, 2022