Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial thinkphp 日志记录没有文件生成

thinkphp 日志记录没有文件生成

Jun 23, 2016 pm 01:45 PM

我在官网文档上看到只要是调试模式 日志就会记录。可我的日志文件怎么弄都不会生成。
index.php内容是:

<?php//缓存路径define('APP_DEBUG',True);define('APP_PATH','./Application/');define('THINK_PATH','./ThinkPHP/');require THINK_PATH.'ThinkPHP.php';?>
Copy after login


页面内容是:
<?phpThink\Log::record('测试日志信息');?>
Copy after login


请问还需要配置什么才会在Logs目录里出现日志文件。


回复讨论(解决方案)

1、日志的记录并非实时保存的,只有当当前请求完成或者异常结束后才会实际写入日志信息,否则只是记录在内存中。
2、record方法只会记录当前配置允许记录的日志级别的信息,所以你还需要配置一下记录的级别:
'LOG_LEVEL' =>'EMERG,ALERT,CRIT,ERR', // 只记录EMERG ALERT CRIT ERR 错误
3、采用record方法记录的日志信息不是实时保存的,如果需要实时记录的话,可以采用write方法,write方法写入日志的时候 不受配置的允许日志级别影响,可以实时写入任意级别的日志信息:
Think\Log::write('测试日志信息,这是警告级别,并且实时写入','WARN');

调试模式会自动开启debug.php

/** * ThinkPHP 默认的调试模式配置文件 */defined('THINK_PATH') or exit();// 调试模式下面默认设置 可以在应用配置目录下重新定义 debug.php 覆盖return  array(    'LOG_RECORD'            =>  true,  // 进行日志记录    'LOG_EXCEPTION_RECORD'  =>  true,    // 是否记录异常信息日志    'LOG_LEVEL'             =>  'EMERG,ALERT,CRIT,ERR,WARN,NOTIC,INFO,DEBUG,SQL',  // 允许记录的日志级别    'DB_FIELDS_CACHE'       =>  false, // 字段缓存信息    'DB_SQL_LOG'            =>  true, // 记录SQL信息    'TMPL_CACHE_ON'         =>  false,        // 是否开启模板编译缓存,设为false则每次都会重新编译    'TMPL_STRIP_SPACE'      =>  false,       // 是否去除模板文件里面的html空格与换行    'SHOW_ERROR_MSG'        =>  true,    // 显示错误信息    'URL_CASE_INSENSITIVE'  =>  false,  // URL区分大小写);
Copy after login

我将 页面内容改为

<?phpThink\Log::record('测试调试错误信息', Think\Log::INFO);Think\Log::save();?>
Copy after login



还是没用。Logs目录就是不生成文件。。求解

你是部署问题还是啥哟?检查下文件夹下的操作权限。

http://document.thinkphp.cn/manual_3_2.html#log
http://blog.sina.com.cn/s/blog_7fb1495b0100xkk8.html
看看就会了

楼主,你的问题很可能是你把Runtime/Logs/下面的Home目录,或者你绑定的其它目录给删除了。重建一个看看。

你是操作的HOME模块吗 如果不是 像我操作的是Admin模块 就自己在Runtime/Logs/下建一个Admin目录

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
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months 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)

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Customizing/Extending Frameworks: How to add custom functionality. Customizing/Extending Frameworks: How to add custom functionality. Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

What exactly is the non-blocking feature of ReactPHP? How to handle its blocking I/O operations? What exactly is the non-blocking feature of ReactPHP? How to handle its blocking I/O operations? Apr 01, 2025 pm 03:09 PM

An official introduction to the non-blocking feature of ReactPHP in-depth interpretation of ReactPHP's non-blocking feature has aroused many developers' questions: "ReactPHPisnon-blockingbydefault...

See all articles