diff --git a/application/forms/Config/General/LoggingConfigForm.php b/application/forms/Config/General/LoggingConfigForm.php index 5f1b27a4d..46588779c 100644 --- a/application/forms/Config/General/LoggingConfigForm.php +++ b/application/forms/Config/General/LoggingConfigForm.php @@ -39,6 +39,7 @@ class LoggingConfigForm extends Form 'label' => $this->translate('Logging Type'), 'description' => $this->translate('The type of logging to utilize.'), 'multiOptions' => array( + 'php' => $this->translate('Webserver Log', 'app.config.logging.type'), 'syslog' => 'Syslog', 'file' => $this->translate('File', 'app.config.logging.type'), 'none' => $this->translate('None', 'app.config.logging.type') @@ -64,7 +65,7 @@ class LoggingConfigForm extends Form ); } - if (false === isset($formData['logging_log']) || $formData['logging_log'] === 'syslog') { + if (false === isset($formData['logging_log']) || in_array($formData['logging_log'], array('syslog', 'php'))) { $this->addElement( 'text', 'logging_application', @@ -72,7 +73,7 @@ class LoggingConfigForm extends Form 'required' => true, 'label' => $this->translate('Application Prefix'), 'description' => $this->translate( - 'The name of the application by which to prefix syslog messages.' + 'The name of the application by which to prefix log messages.' ), 'requirement' => $this->translate('The application prefix must not contain whitespace.'), 'value' => 'icingaweb2', diff --git a/application/locale/de_DE/LC_MESSAGES/icinga.mo b/application/locale/de_DE/LC_MESSAGES/icinga.mo index d6f05c01e..c538f9dc0 100644 Binary files a/application/locale/de_DE/LC_MESSAGES/icinga.mo and b/application/locale/de_DE/LC_MESSAGES/icinga.mo differ diff --git a/application/locale/de_DE/LC_MESSAGES/icinga.po b/application/locale/de_DE/LC_MESSAGES/icinga.po index f99ff565c..37cf95ea2 100644 --- a/application/locale/de_DE/LC_MESSAGES/icinga.po +++ b/application/locale/de_DE/LC_MESSAGES/icinga.po @@ -2979,6 +2979,11 @@ msgctxt "app.config.logging.level" msgid "Warning" msgstr "Warnung" +#: /vagrant/application/forms/Config/General/LoggingConfigForm.php:40 +msgctxt "app.config.logging.type" +msgid "Webserver Log" +msgstr "Webserver-Log" + #: /vagrant/application/views/scripts/authentication/login.phtml:5 msgid "" "Welcome to Icinga Web 2. For users of the screen reader Jaws full and " diff --git a/library/Icinga/Application/Logger/Writer/PhpWriter.php b/library/Icinga/Application/Logger/Writer/PhpWriter.php new file mode 100644 index 000000000..310cd7678 --- /dev/null +++ b/library/Icinga/Application/Logger/Writer/PhpWriter.php @@ -0,0 +1,45 @@ +ident = $config->get('application', 'icingaweb2'); + } + + /** + * {@inheritdoc} + */ + public function log($severity, $message) + { + if (! error_log($this->ident . ': ' . Logger::$levels[$severity] . ' - ' . ( + ini_get('error_log') === 'syslog' ? str_replace("\n", ' ', $message) : $message + ))) { + throw new NotWritableError('Could not log to ' . (ini_get('error_log') ?: 'SAPI')); + } + } +} diff --git a/modules/setup/library/Setup/Steps/GeneralConfigStep.php b/modules/setup/library/Setup/Steps/GeneralConfigStep.php index 002bd965b..95597f5c3 100644 --- a/modules/setup/library/Setup/Steps/GeneralConfigStep.php +++ b/modules/setup/library/Setup/Steps/GeneralConfigStep.php @@ -70,12 +70,24 @@ class GeneralConfigStep extends Step $loggingHtml = '

' . mt('setup', 'Logging will be disabled.') . '

'; } else { $level = $this->data['generalConfig']['logging_level']; + switch ($type) { + case 'syslog': + $typeText = t('Syslog', 'app.config.logging.type'); + break; + case 'php': + $typeText = t('Webserver Log', 'app.config.logging.type'); + break; + case 'file': + $typeText = t('File', 'app.config.logging.type'); + break; + } + $loggingHtml = '' . '' . '' . '' . '' - . '' + . '' . '' . '' . '' @@ -88,7 +100,7 @@ class GeneralConfigStep extends Step )) . '' . '' . '' - . ($type === 'syslog' ? ( + . ($type !== 'file' ? ( '' . '' ) : (
' . t('Type', 'app.config.logging') . '' . ($type === 'syslog' ? 'Syslog' : t('File', 'app.config.logging.type')) . '' . $typeText . '
' . t('Level', 'app.config.logging') . '
' . t('Application Prefix') . '' . $this->data['generalConfig']['logging_application'] . '