等价于PHP error_log的信息日志? [英] Equivalent of PHP error_log for info logs?

查看:49
本文介绍了等价于PHP error_log的信息日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 error_log 进行日志记录,但是我意识到必须有一种更惯用的方式来记录应用程序进度.是否有 info_log ?或等效的?

I use error_log for my logging, but I'm realizing that there must be a more idiomatic way to log application progress. is there an info_log ? or equivalent ?

推荐答案

您可以使用 error_log 附加到指定文件.

You can use error_log to append to a specified file.

error_log($myMessage, 3, 'my/file/path/log.txt');

请注意,您需要具有3(消息类型)才能附加到给定文件.

Note that you need to have the 3 (message type) in order to append to the given file.

您可以在脚本的早期创建一个函数来包装此功能:

You can create a function early on in your script to wrap this functionality:

function log_message($message) {
    error_log($message, 3, 'my/file/path/log.txt');   
}

这篇关于等价于PHP error_log的信息日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆