Library for sending Graylog Extended Log Format (GELF) messages from C++ applications.
gelfcpp is a Graylog Extended Log Format (GELF) interface for C++. GELF is used by the open-source log management software Graylog. It is able to send structured message log message into the system without the need to do expensive parsing.
- CMake >= 3.1
- C++14 compatible compiler
- GCC >= 5.4.0
- Clang >= 3.8.0
- MSVC >= 14.2
- Boost
- system
- iostreams (optional, for compression)
- rapidjson v1.1.0 (included)
- googetest v1.8.0 (included) (for tests only)
- Doxygen (for documentation only)
gelfcpp is header only and does not require building itself.
There are two methods for for including gelfcpp depending on your setup. The recommended approach is Variant 2: CMake subproject and directly checking out this reposity into your project. This way you can easily stay up to date with new releases!
- Just copy everything in the include/ directory to your project and/or add gelfcpp to your include path.
- Verify that you provide
rapidjson
andBoost
in your setup. - Use it! See Examples.
- Use the distribution as is (required
CMakeLists.txt
,dep/
,include/
) - Add gelfcpp via CMake:
set(GELFCPP_AS_SUBPROJECT 1)
add_subdirectory(gelfcpp)
- This includes already both dependencies.
- Link your library/executable against the
gelfcpp
target in cmake:
add_executable(my_cool_project main.cpp)
target_link_libraries(my_cool_project PUBLIC gelfcpp)
- Use it! See Examples.
See Examples folder for further examples.
Sending messages to your Graylog instance.
#include <gelfcpp/GelfMessageStream.hpp>
#include <gelfcpp/output/GelfUDPOutput.hpp>
#include <gelfcpp/decorator/Timestamp.hpp>
int main()
{
gelfcpp::output::GelfUDPOutput graylog("graylog.example.com", 12001);
gelfcpp::decorator::CurrentTimestamp timestamp;
GELF_MESSAGE(graylog)
("host", "localhost")
(timestamp)
("I'm sending a message from gelfcpp")
("awesomeness", 1337);
}