Class yii\log\SyslogTarget
| 继承 | yii\log\SyslogTarget » yii\log\Target » yii\base\Component » yii\base\BaseObject |
|---|---|
| 实现 | yii\base\Configurable |
| 可用版本自 | 2.0 |
| 源码 | https://github.com/yiichina/yii2/blob/api/framework/log/SyslogTarget.php |
SyslogTarget 将日志写入系统日志(syslog)中。
公共属性
| 属性 | 类型 | 描述 | 被定义在 |
|---|---|---|---|
| $behaviors | yii\base\Behavior[] | List of behaviors attached to this component | yii\base\Component |
| $categories | array | 需要记录的消息类别列表。 默认为空,表示所有类别。 您可以在类别末尾使用星号,以便可以使用该类别来匹配共享相同公共前缀的类别。 例如,'yii\db*' 将匹配以 'yii\db\' 开头的类别,例如 'yii\db\Connection'。 | yii\log\Target |
| $enabled | boolean|callable | 一个布尔值或一个可调用的函数返回值。 从 2. | yii\log\Target |
| $except | array | 需要排除的消息类别列表。 默认为空,表示没有需要排除的消息。 如果此属性不为空,则此处列出的任何类别都将从 $categories 中排除。 您可以在类别末尾使用星号,以便该类别可用于匹配共享相同公共前缀的类别。 例如,'yii\db*' 将匹配以 'yii\db\' 开头的类别,例如 'yii\db\Connection'。 | yii\log\Target |
| $exportInterval | integer | 累积多少条消息后才导出。默认值为 1000。 请注意,应用程序终止时将始终会导出消息。 如果将此属性设置为 0,则只会在应用程序终止之时导出消息。 | yii\log\Target |
| $facility | integer | 系统日志(syslog)类型 | yii\log\SyslogTarget |
| $identity | string | 系统日志(syslog)标识 | yii\log\SyslogTarget |
| $levels | integer | 需要记录的消息级别。 默认为 0,表示所有可用级别。 | yii\log\Target |
| $logVars | array | 需要记录在消息中的PHP预定义变量的列表。
请注意,必须可以通过 $GLOBALS 访问变量。否则将不会记录。
默认是 ['_GET', '_POST', '_FILES', '_COOKIE', '_SESSION', '_SERVER']。
从版本 2. |
yii\log\Target |
| $messages | array | 此日志目标从记录器中获得的消息。 请参阅 yii\log\Logger::$messages 以获取有关消息结构的详细信息。 | yii\log\Target |
| $microtime | boolean | 是否以微秒记录时间。 默认是 false。 | yii\log\Target |
| $options | integer | Openlog(打开与系统记录器的连接)选项。这是传递给函数 [openlog()](http://php. | yii\log\SyslogTarget |
| $prefix | callable | 一个可调用的函数,它返回一个字符串,以便为每个导出的消息添加前缀。
如果未设置,将使用 getMessagePrefix(),该消息在消息前面加上上下文信息。
例如用户 IP,用户 ID 和会话 ID。
可调用的函数应该是 function ($message)。 |
yii\log\Target |
公共方法
| 方法 | 描述 | 被定义在 |
|---|---|---|
| __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 |
| __construct() | Constructor. | yii\base\BaseObject |
| __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() | Returns the fully qualified name of this class. | yii\base\BaseObject |
| collect() | 处理给定的日志消息。 此方法将使用 $levels 和 $categories 过滤给定的消息。 如果需要,它还会将过滤结果导出到特定介质(例如电子邮件)。 | yii\log\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() | 将日志消息写入系统日志(syslog)中。 从版本 2.0.14 开始,如果日志无法导出,将抛出异常 LogRuntimeException。 | yii\log\SyslogTarget |
| filterMessages() | 根据类别和级别过滤给定的消息。 | yii\log\Target |
| formatMessage() | 为便于显示将日志消息格式化为字符串。 | yii\log\SyslogTarget |
| getBehavior() | Returns the named behavior object. | yii\base\Component |
| getBehaviors() | Returns all behaviors attached to this component. | yii\base\Component |
| getEnabled() | 检查日志目标是否已启用。 | yii\log\Target |
| getLevels() | yii\log\Target | |
| getMessagePrefix() | 返回要添加到给定消息前缀的字符串。 如果配置了 $prefix,它将返回回调的结果。 默认将返回用户 IP,用户 ID 和会话 ID 作为前缀。 | yii\log\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. | yii\log\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() | 设置是否启用此日志目标。 | yii\log\Target |
| setLevels() | 设置此目标需要记录的消息级别。 | yii\log\Target |
| trigger() | Triggers an event. | yii\base\Component |
受保护的方法
| 方法 | 描述 | 被定义在 |
|---|---|---|
| getContextMessage() | 生成要记录的上下文信息。 默认会存储用户信息,系统变量等。 | yii\log\Target |
| getTime() | 返回格式化以后的消息时间戳,格式为:'Y-m-d H:i:s'。 如果 $microtime 配置为 true,则格式为 'Y-m-d H:i:s.u'。 | yii\log\Target |
属性详情
系统日志(syslog)类型
系统日志(syslog)标识
Openlog(打开与系统记录器的连接)选项。这是传递给函数 openlog() 中 $option 参数的值。
当值为 null 时,表示使用默认值 LOG_ODELAY | LOG_PID。
参见 [[访问]] http://php.net/openlog 可获取更多可用选项。.
方法详情
将日志消息写入系统日志(syslog)中。 从版本 2.0.14 开始,如果日志无法导出,将抛出异常 LogRuntimeException。
| public void export() | ||
| throws | yii\log\LogRuntimeException | |
|---|---|---|
为便于显示将日志消息格式化为字符串。
| public string formatMessage($message) | ||
| $message | array | 要格式化的日志消息。 消息结构遵循 yii\log\Logger::$messages 中的消息结构。 |
| return | string | 格式化后的消息 |
|---|---|---|
Initializes the object.
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
| public void init() |