diff --git a/application/forms/Config/General/LoggingConfigForm.php b/application/forms/Config/General/LoggingConfigForm.php index 1ca6bf8dd..6a5cb9238 100644 --- a/application/forms/Config/General/LoggingConfigForm.php +++ b/application/forms/Config/General/LoggingConfigForm.php @@ -63,7 +63,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', @@ -71,7 +71,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/library/Icinga/Application/Logger/Writer/PhpWriter.php b/library/Icinga/Application/Logger/Writer/PhpWriter.php index 51c2fea77..913ea07de 100644 --- a/library/Icinga/Application/Logger/Writer/PhpWriter.php +++ b/library/Icinga/Application/Logger/Writer/PhpWriter.php @@ -5,6 +5,7 @@ namespace Icinga\Application\Logger\Writer; use Icinga\Application\Logger; use Icinga\Application\Logger\LogWriter; +use Icinga\Data\ConfigObject; use Icinga\Exception\NotWritableError; /** @@ -14,12 +15,30 @@ use Icinga\Exception\NotWritableError; */ class PhpWriter extends LogWriter { + /** + * Prefix to prepend to each message + * + * @var string + */ + protected $ident; + + /** + * {@inheritDoc} + */ + public function __construct(ConfigObject $config) + { + parent::__construct($config); + $this->ident = $config->get('application', 'icingaweb2'); + } + /** * {@inheritdoc} */ public function log($severity, $message) { - if (! error_log(Logger::$levels[$severity] . ' - ' . str_replace("\n", ' ', $message))) { + if (! error_log( + $this->ident . ': ' . Logger::$levels[$severity] . ' - ' . str_replace("\n", ' ', $message) + )) { throw new NotWritableError('Could not log to ' . (ini_get('error_log') ?: 'SAPI')); } }