-D [ --define] args define a constant
-c [ --config ] arg parse a configuration file
-C [ --validate ] exit after validating the configuration
- -x [ --debug ] enable debugging
+ -x [ --debug ] arg enable debugging with optional severity level specified
-d [ --daemonize ] detach from the controlling terminal
-e [ --errorlog ] arg log fatal errors to the specified log file (only works
in combination with --daemonize)
`severity` attribute of the [logs](#logging) to `notice` or
`debug`.
-Additionally you can enable the debug log using
-
- # icinga2-enable-feature debuglog
- # service icinga2 restart
- # tail -f /var/log/icinga2/debug.log
-
## <a id="troubleshooting-information-required"></a> Which information is required
* Which distribution and version
* If the check command failed - what's the output of your manual plugin tests?
* In case of [debugging](#debug) Icinga 2, the full back traces and outputs
+## <a id="troubleshooting-enable-debug-output"></a> Enable Debug Output
+
+Run Icinga 2 in foreground with debugging enabled You can specify the debug
+log severity as additional parameter argument to `-x` (or `--debug`). Default
+is `debug`.
+
+ # /usr/sbin/icinga2 -c /etc/icinga2/icinga2.conf -x notice
+
+Additionally you can enable the debug log using
+
+ # icinga2-enable-feature debuglog
+ # service icinga2 restart
+ # tail -f /var/log/icinga2/debug.log
+
## <a id="checks-not-executed"></a> Checks are not executed
* Check the debug log if the check command gets executed
("config,c", po::value<std::vector<std::string> >(), "parse a configuration file")
("no-config,z", "start without a configuration file")
("validate,C", "exit after validating the configuration")
- ("debug,x", "enable debugging")
+ ("debug,x", po::value<std::string>(), "enable debugging with optional severity level specified")
("errorlog,e", po::value<std::string>(), "log fatal errors to the specified log file (only works in combination with --daemonize)")
#ifndef _WIN32
("reload-internal", po::value<int>(), "used internally to implement config reload: do not call manually, send SIGHUP instead")
}
#endif /* _WIN32 */
- if (g_AppParams.count("debug"))
+ if (g_AppParams.count("debug")) {
Application::SetDebugging(true);
+ String debug_severity = g_AppParams["debug"].as<std::string>();
+
+ if (!debug_severity.IsEmpty())
+ Application::SetDebuggingSeverity(Logger::StringToSeverity(debug_severity));
+ }
+
if (g_AppParams.count("help") || g_AppParams.count("version")) {
String appName = Utility::BaseName(argv[0]);
pid_t Application::m_ReloadProcess = 0;
static bool l_Restarting = false;
bool Application::m_Debugging = false;
+LogSeverity Application::m_DebuggingSeverity = LogDebug;
int Application::m_ArgC;
char **Application::m_ArgV;
double Application::m_StartTime;
return m_Debugging;
}
+/**
+ * Sets debugging severity.
+ *
+ * @param severity Debug log severity.
+ */
+void Application::SetDebuggingSeverity(LogSeverity severity)
+{
+ Application::m_DebuggingSeverity = severity;
+}
+
+/**
+ * Retrieves the debugging severity of the application.
+ *
+ * @returns severity 'debug' if not set, severity value otherwise.
+ */
+LogSeverity Application::GetDebuggingSeverity(void)
+{
+ if (!Application::m_DebuggingSeverity)
+ return LogDebug;
+
+ return Application::m_DebuggingSeverity;
+}
+
/**
* Display version information.
*/
#include "base/application.th"
#include "base/threadpool.h"
#include "base/utility.h"
+#include "base/logger_fwd.h"
namespace icinga
{
static void SetDebugging(bool debug);
static bool IsDebugging(void);
+ static void SetDebuggingSeverity(LogSeverity severity);
+ static LogSeverity GetDebuggingSeverity(void);
+
void UpdatePidFile(const String& filename, pid_t pid = Utility::GetPid());
void ClosePidFile(bool unlink);
static pid_t ReadPidFile(const String& filename);
static char **m_ArgV; /**< Command-line arguments. */
FILE *m_PidFile; /**< The PID file */
static bool m_Debugging; /**< Whether debugging is enabled. */
+ static LogSeverity m_DebuggingSeverity; /**< Whether debugging severity is set. */
static double m_StartTime;
#ifndef _WIN32
LogSeverity defaultLogLevel;
if (Application::IsDebugging())
- defaultLogLevel = LogDebug;
+ defaultLogLevel = Application::GetDebuggingSeverity();
else
defaultLogLevel = LogInformation;