thinkphp 日志记录没有文件生成
我在官网文档上看到只要是调试模式 日志就会记录。可我的日志文件怎么弄都不会生成。
index.php内容是:
<?php//缓存路径define('APP_DEBUG',True);define('APP_PATH','./Application/');define('THINK_PATH','./ThinkPHP/');require THINK_PATH.'ThinkPHP.php';?>页面内容是:
<?phpThink\Log::record('测试日志信息');?>请问还需要配置什么才会在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区分大小写); 我将 页面内容改为
<?phpThink\Log::record('测试调试错误信息', Think\Log::INFO);Think\Log::save();?>还是没用。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目录
Hot AI Tools
Undresser.AI Undress
AI-powered app for creating realistic nude photos
AI Clothes Remover
Online AI tool for removing clothes from photos.
Undress AI Tool
Undress images for free
Clothoff.io
AI clothes remover
AI Hentai Generator
Generate AI Hentai for free.
Hot Article
Hot Tools
Notepad++7.3.1
Easy-to-use and free code editor
SublimeText3 Chinese version
Chinese version, very easy to use
Zend Studio 13.0.1
Powerful PHP integrated development environment
Dreamweaver CS6
Visual web development tools
SublimeText3 Mac version
God-level code editing software (SublimeText3)
Hot Topics
1377
52
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.
Alipay PHP SDK transfer error: How to solve the problem of 'Cannot declare class SignData'?
Apr 01, 2025 am 07:21 AM
Alipay PHP...
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.
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.
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?
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.
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?
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...


