Skip to content
PHP Ecosystem
Explore

SyslogTarget

API reference › yii › log › SyslogTarget

classyii\log\SyslogTarget
ExtendsTarget » yii\base\Component » yii\base\BaseObject
Implementsyii\base\Configurable
Since2.0
Sourceframework/log/SyslogTarget.php

SyslogTarget writes log to syslog.

PropertyTypeDescriptionDefined by
$behaviors read-onlyarray<yii\base\Behavior<static>>List of behaviors attached to this component.yii\base\Component
$categorieslist<string>List of message categories that this target is interested in. Default: [].Target
$enabledbool|callableA boolean value or a callable to obtain the value from.Target
$exceptlist<string>List of message categories that this target is NOT interested in. Default: [].Target
$exportIntervalintHow many messages should be accumulated before they are exported. Default: 1000.Target
$facilityintSyslog facility. Default: LOG_USER.SyslogTarget
$identitystringSyslog identity Default: null.SyslogTarget
$levelsarray|intMessage levels that this target is interested in.Target
$logVarslist<string>List of the PHP predefined variables that should be logged in a message. Default: ['_GET', '_POST', '_FILES', '_COOKIE', '_SESSION', '_SERVER'].Target
$maskVarslist<string>List of the PHP predefined variables that should NOT be logged “as is” and should always be replaced with a mask *** before logging, when exist. Default: ['_SERVER.HTTP_AUTHORIZATION', '_SERVER.PHP_AUTH_USER', '_SERVER.PHP_AUTH_PW']. Available since 2.0.16.Target
$messageslist<yii\log\LogMessage>The messages that are retrieved from the logger so far by this log target. Default: [].Target
$microtimeboolWhether to log time with microseconds. Default: false. Available since 2.0.13.Target
$optionsint|nullOpenlog options. Default: null. Available since 2.0.11.SyslogTarget
$prefixcallable(yii\log\LogMessage): string|nullA PHP callable that returns a string to be prefixed to every exported message. Default: null.Target
MethodDescriptionDefined by
__construct()Constructor.yii\base\BaseObject
__call()Calls the named method which is not a class method.yii\base\Component
__clone()This method is called after the object is created by cloning an existing one.yii\base\Component
__get()Returns the value of a component property.yii\base\Component
__isset()Checks if a property is set, i.e. defined and not null.yii\base\Component
__set()Sets the value of a component property.yii\base\Component
__unset()Sets a component property to be null.yii\base\Component
attachBehavior()Attaches a behavior to this component.yii\base\Component
attachBehaviors()Attaches a list of behaviors to the component.yii\base\Component
behaviors()Returns a list of behaviors that this component should behave as.yii\base\Component
canGetProperty()Returns a value indicating whether a property can be read.yii\base\Component
canSetProperty()Returns a value indicating whether a property can be set.yii\base\Component
className() staticReturns the fully qualified name of this class.yii\base\BaseObject
collect()Processes the given log messages.Target
detachBehavior()Detaches a behavior from the component.yii\base\Component
detachBehaviors()Detaches all behaviors from the component.yii\base\Component
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.yii\base\Component
export()Writes log messages to syslog.SyslogTarget
filterMessages() staticFilters the given messages according to their categories and levels.Target
formatMessage()Formats a log message for display as a string.SyslogTarget
getBehavior()Returns the named behavior object.yii\base\Component
getBehaviors()Returns all behaviors attached to this component.yii\base\Component
getEnabled()Check whether the log target is enabled.Target
getLevels()Target
getMessagePrefix()Returns a string to be prefixed to the given message.Target
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.yii\base\Component
hasMethod()Returns a value indicating whether a method is defined.yii\base\Component
hasProperty()Returns a value indicating whether a property is defined for this component.yii\base\Component
init()Initializes the object.SyslogTarget
off()Detaches an existing event handler from this component.yii\base\Component
on()Attaches an event handler to an event.yii\base\Component
setEnabled()Sets a value indicating whether this log target is enabled.Target
setLevels()Sets the message levels that this target is interested in.Target
trigger()Triggers an event.yii\base\Component
formatMessageText() protectedConverts a log message value to text.Target
getContextMessage() protectedGenerates the context information to be logged.Target
getTime() protectedReturns formatted (‘Y-m-d H:i:s’) timestamp for message.Target
public int|null $options = null

Openlog options.

This is a bitfield passed as the $option parameter to openlog(). Defaults to null which means to use the default options LOG_ODELAY | LOG_PID.

Since

2.0.11

public function export(): mixed

Writes log messages to syslog.

Starting from version 2.0.14, this method throws LogRuntimeException in case the log can not be exported.

Returns

mixed

Throws

public function formatMessage(mixed $message): string

Formats a log message for display as a string.

Parameters

ParameterTypeDescription
$messagemixedThe log message to be formatted. The message structure follows that in Logger::$messages.

Returns

string: The formatted message

public function init(): mixed

Initializes the object.

This method is invoked at the end of the constructor after the object is initialized with the given configuration.

Returns

mixed