Documentation

FileTarget extends FileTarget
in package

FileTarget records log messages in a file.

The log file is specified via [[logFile]]. If the size of the log file exceeds [[maxFileSize]] (in kilo-bytes), a rotation will be performed, which renames the current log file by suffixing the file name with '.1'. All existing log files are moved backwards by one place, i.e., '.2' to '.3', '.1' to '.2', and so on. The property [[maxLogFiles]] specifies how many history files to keep.

Tags
author

Qiang Xue qiang.xue@gmail.com

since
2.0

Table of Contents

$enableRotation  : bool
$logVars  : array<string|int, mixed>
export()  : mixed
Writes log messages to a file.
formatMessage()  : string
Formats a log message for display as a string.
init()  : mixed
Initializes the route.
getContextMessage()  : string
Generates the context information to be logged.

Properties

$enableRotation

public bool $enableRotation = false
Tags
since
2.0.3

$logVars

public array<string|int, mixed> $logVars = ['_GET', '_POST', '_FILES', '_COOKIE', '_SESSION']

Methods

export()

Writes log messages to a file.

public export() : mixed
Tags
throws
InvalidConfigException

if unable to open the log file for writing

Return values
mixed

formatMessage()

Formats a log message for display as a string.

public formatMessage(array<string|int, mixed> $message) : string
Parameters
$message : array<string|int, mixed>

the log message to be formatted. The message structure follows that in [[Logger::messages]]

Return values
string

the formatted message

init()

Initializes the route.

public init() : mixed

This method is invoked after the route is created by the route manager.

Return values
mixed

getContextMessage()

Generates the context information to be logged.

protected getContextMessage() : string

The default implementation will dump user information, system variables, etc.

Return values
string

the context information. If an empty string, it means no context information

Search results