Table of Contents
Yii2.0中文开发向导——自定义日志文件写日志,yii2.0日志文件
Home php教程 php手册 Yii2.0中文开发向导自定义日志文件写日志,yii2.0日志文件

Yii2.0中文开发向导自定义日志文件写日志,yii2.0日志文件

Jun 13, 2016 am 08:56 AM
log file

Yii2.0中文开发向导——自定义日志文件写日志,yii2.0日志文件

头部引入log类
use yii\log\FileTarget;


$time = microtime(true);
$log = new FileTarget();
$log->logFile = Yii::$app->getRuntimePath() . '/logs/zhidemy.com.log'; //文件名自定义
$log->messages[] = ['test',1,'application',$time];
$log->export();


这样基本就能写出来了,先看一下$log->message的类描述信息
/*
* [0] => message (mixed, can be a string or some complex data, such as an exception object)
* [1] => level (integer)
* [2] => category (string)
* [3] => timestamp (float, obtained by microtime(true))
* [4] => traces (array, debug backtrace, contains the application code call stacks)
*/

传递参数按照这些信息进行传递就可以了。最后记住重要的一点
$log->messages[] 别忘了加[] 
具体可查看Target类

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Python script to monitor network connections and save to log file Python script to monitor network connections and save to log file Sep 01, 2023 am 10:41 AM

Monitoring network connections is critical to ensuring the stability and security of your computer system. Whether you are a network administrator or an individual user, having a way to track network connections and log related information can be invaluable. In this blog post, we will explore how to create a Python script to monitor network connections and save the data to a log file. By leveraging the power of Python and its rich libraries, we can develop a script to periodically check network status, capture relevant details such as IP address, timestamp, and connection status, and store them in a log file for future use refer to. This script not only provides real-time insights into network connections, but also provides historical records that aid in troubleshooting and analysis. Set up the environment before starting to write P

Where are the win10 log files? Where are the win10 log files? Jan 05, 2024 am 08:15 AM

The win10 log can help users understand the system usage in detail, and can help users record usage and problems. Many new users may not know how to open it. Let’s take a look at its detailed tutorial below. Where are the win10 log files: 1. Open "Control Panel" in settings 2. Click "Administrative Tools" 3. Find "Event Viewer" 4. Double-click "Windows Log" to open

Linux server log is too large, how to solve it? Linux server log is too large, how to solve it? Jun 29, 2023 pm 11:09 PM

Common problems of too-large log files on Linux servers and their solutions. With the rapid development of the Internet and the widespread use of servers, it has become a common problem that server log files are getting larger and larger. A large amount of log data not only takes up disk space, but may also affect the performance and operational stability of the server. This article will discuss the common problem of too large log files on Linux servers and provide some solutions. 1. Common log files on Linux servers. Common log files include system logs, application logs, We

Windows log files are located in C:\Windows\system32\logfiles Windows log files are located in C:\Windows\system32\logfiles Dec 22, 2023 pm 05:43 PM

Many users have encountered the situation of c: Windows\system32\logfiles on the win10 system. Nothing happens when pressing anything. Today, let’s take a look at how to solve this problem. win10 log file c: Windows\system32\logfiles: 1. Open the run, enter regedit to open, find HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ShellFolders, find "desktop" on the right, right-click to modify, and change the

Common log file permission errors on Linux servers and how to fix them Common log file permission errors on Linux servers and how to fix them Jun 29, 2023 am 09:02 AM

Title: Common log file permission errors on Linux servers and how to fix them When running a Linux server, log files are very important. Successfully managing and protecting your server's log files is key to ensuring server security and stability. However, due to misconfiguration, attacks, or unexpected circumstances, log file permission errors may occur, resulting in limited access to the log file or the inability to write to the log. This article discusses some common log file permission errors and provides corresponding fixes to help administrators resolve the issue.

Is it possible to delete Win10 log files? Is it possible to delete Win10 log files? Dec 26, 2023 pm 06:37 PM

The logs of win10 can help users understand the system usage in detail, and can help users record usage and problems. Most users will worry about whether its log files can be deleted. Let’s take a look at its details below. Can win10 log files be deleted? 1. The logs folder is the system log folder. This folder is used to record information about hardware, software and system problems in the system. It also monitors events that occur in the system, such as when our computer just If there is a problem with the computer crashing or automatically restarting, we can use it to check the cause of the error, or if the computer is attacked, we can also find traces of the attack from this folder. So the folder can be deleted. 2. We have performed any operations in the Win10 system,

Shell is an efficient command for analyzing log files, super easy to use! Shell is an efficient command for analyzing log files, super easy to use! Aug 01, 2023 pm 04:47 PM

My own small website runs on Alibaba Cloud's ECS. I occasionally analyze my website server logs to see the number of visits to the website. See if there are any hackers causing damage! So I collected and sorted out some server log analysis commands. You can try them!

Learn more about the types and functions of Linux log files Learn more about the types and functions of Linux log files Feb 26, 2024 pm 10:33 PM

Detailed explanation of Linux log file types and functions In Linux systems, log files are a very important tool for administrators and developers. They record the operating status, behavior and events of the system. By analyzing log files, we can understand the operation of the system, discover problems in time and troubleshoot them. This article will introduce in detail the common log file types and their functions in Linux systems, and provide specific code examples to illustrate. 1. System log (/var/log/messages) The system log is L

See all articles