SyslogTarget
API reference › yii › log › SyslogTarget
SyslogTarget writes log to syslog.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$behaviors read-only | array<yii\<static>> | List of behaviors attached to this component. | yii\ |
$categories | list<string> | List of message categories that this target is interested in. Default: []. | Target |
$enabled | bool| | A boolean value or a callable to obtain the value from. | Target |
$except | list<string> | List of message categories that this target is NOT interested in. Default: []. | Target |
$exportInterval | int | How many messages should be accumulated before they are exported. Default: 1000. | Target |
$facility | int | Syslog facility. Default: LOG_USER. | SyslogTarget |
$identity | string | Syslog identity Default: null. | SyslogTarget |
$levels | array| | Message levels that this target is interested in. | Target |
$logVars | list<string> | List of the PHP predefined variables that should be logged in a message. Default: ['_GET',. | Target |
$maskVars | list<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',. Available since 2.0.16. | Target |
$messages | list<yii\ | The messages that are retrieved from the logger so far by this log target. Default: []. | Target |
$microtime | bool | Whether to log time with microseconds. Default: false. Available since 2.0.13. | Target |
$options | int| | Openlog options. Default: null. Available since 2.0.11. | SyslogTarget |
$prefix | callable(yii\ | A PHP callable that returns a string to be prefixed to every exported message. Default: null. | Target |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | yii\ |
__call() | Calls the named method which is not a class method. | yii\ |
__clone() | This method is called after the object is created by cloning an existing one. | yii\ |
__get() | Returns the value of a component property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets the value of a component property. | yii\ |
__unset() | Sets a component property to be null. | yii\ |
attachBehavior() | Attaches a behavior to this component. | yii\ |
attachBehaviors() | Attaches a list of behaviors to the component. | yii\ |
behaviors() | Returns a list of behaviors that this component should behave as. | yii\ |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
collect() | Processes the given log messages. | Target |
detachBehavior() | Detaches a behavior from the component. | yii\ |
detachBehaviors() | Detaches all behaviors from the component. | yii\ |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\ |
export() | Writes log messages to syslog. | SyslogTarget |
filterMessages() static | Filters 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\ |
getBehaviors() | Returns all behaviors attached to this component. | yii\ |
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\ |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\ |
init() | Initializes the object. | SyslogTarget |
off() | Detaches an existing event handler from this component. | yii\ |
on() | Attaches an event handler to an event. | yii\ |
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\ |
formatMessageText() protected | Converts a log message value to text. | Target |
getContextMessage() protected | Generates the context information to be logged. | Target |
getTime() protected | Returns formatted (‘Y-m-d H:i:s’) timestamp for message. | Target |
Property details
Section titled “Property details”$options
Section titled “$options ”public int|null $options = nullOpenlog 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
Method details
Section titled “Method details”export()
Section titled “export() ”public function export(): mixedWrites log messages to syslog.
Starting from version 2.0.14, this method throws LogRuntimeException in case the log can not be exported.
formatMessage()
Section titled “formatMessage() ”public function formatMessage(mixed $message): stringFormats a log message for display as a string.
Parameters
| Parameter | Type | Description |
|---|---|---|
$message | mixed | The log message to be formatted. The message structure follows that in Logger::$messages. |
Returns
string: The formatted message
init()
Section titled “init() ”public function init(): mixedInitializes the object.
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
Returns
mixed