-
I am trying to write to "custom_file.log" file in /var/log directory. My OS is CentOS. What I have tried to far: Adding line
to "/etc/rsyslog.conf" file. Then entering command "sudo service rsyslog restart" to restart rsyslog. After that, I am just using the most basic example for syslog facility of spdlog:
Note that I am using LOG_LOCAL2 syslog facility here. However, the message won't be printed to "/var/log/custom_file.log". To see if LOG_LOCAL2 facility is not at fault, I tried logging via Linux syscalls:
This works as intended. So, my question is, first of all, is it possible to write to a custom log file via spdlog. If so, where exactly am I wrong here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
First of all, I don't usually use syslog, so I may be guiding you wrongly. Looking at the function declaration, it is the fourth argument of spdlog/include/spdlog/sinks/syslog_sink.h Lines 95 to 101 in eb32206 spdlog/include/spdlog/sinks/syslog_sink.h Lines 24 to 37 in eb32206
std::string ident = "spdlog-example";
auto syslog_logger = spdlog::syslog_logger_mt("syslog", ident, LOG_CONS | LOG_NDELAY, LOG_LOCAL2);
syslog_logger->warn("This is warning that will end up in syslog."); |
Beta Was this translation helpful? Give feedback.
First of all, I don't usually use syslog, so I may be guiding you wrongly.
Looking at the function declaration, it is the fourth argument of
spdlog::syslog_logger_mt()
that corresponds to the third argumentfacility
ofopenlog()
.spdlog/include/spdlog/sinks/syslog_sink.h
Lines 95 to 101 in eb32206