public static method

Writes a message to one or more log adapters, where the adapters that are written to are the ones that respond to the given priority level.


  • string $priority

    The priority of the log message to be written.

  • string $message

    The message to be written.

  • array $options

    An array of adapter-specific options that may be passed when writing log messages. Some options are also handled by Logger itself:

    • 'name' string: This option can be specified if you wish to write to a specific adapter configuration, instead of writing to the adapter(s) that respond to the given priority.



Returns true if all log writes succeeded, or false if any or all writes failed.


This method can be filtered.


	public static function write($priority, $message, array $options = []) {
		$defaults = ['name' => null];
		$options += $defaults;
		$result = true;

		if (isset(static::$_configurations[$options['name']])) {
			$name = $options['name'];
			$methods = [$name => static::adapter($name)->write($priority, $message, $options)];
		} elseif (!isset(static::$_priorities[$priority])) {
			$message = "Attempted to write log message with invalid priority `{$priority}`.";
			throw new UnexpectedValueException($message);
		} else {
			$methods = static::_configsByPriority($priority, $message, $options);

		foreach ($methods as $name => $method) {
			$params = compact('priority', 'message', 'options');
			$config = static::_config($name);

			if (!empty($config['filters'])) {
				$message  = 'Per adapter filters have been deprecated. Please ';
				$message .= "filter the manager class' static methods instead.";
				trigger_error($message, E_USER_DEPRECATED);

				$r = Filters::bcRun(
					get_called_class(), __FUNCTION__, $params, $method, $config['filters']
			} else {
				$r = Filters::run(get_called_class(), __FUNCTION__, $params, $method);
			if (!$r) {
				$result = false;
		return $methods ? $result : false;