Strace 追踪 php 模拟页面执行,打印log

2024-03-25 12:08

本文主要是介绍Strace 追踪 php 模拟页面执行,打印log,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.strace可以追踪某个程序,如果是一个执行文件,是可以用strace进行追踪

strace /usr/local/php/bin/php   test.php


但是我们的系统,是用浏览器登录访问,也就是说有request,然后我们的系统进行初始化,然后才能执行,不然会报错

strace -t -f -o  strace.txt  /usr/local/php/bin/php  backend/web/index.php   >> 22.thml


这个是要报错的


因此我们需要加入这些参数 HTTP_HOST   REQUEST_URI  然后再加入strace就可以了

 HTTP_HOST=10.10.10.252:600 REQUEST_URI=/  strace -t -f -o  strace.txt  /usr/local/php/bin/php  backend/web/index.php   >> 22.thml

然后就可以在strace.txt查看所有的日志,22.html是这个index.php生成的html代码。

strace是蛮好用的,譬如我想看看我的系统加载的config文件,我的配置都是放到了config文件夹下面


HTTP_HOST=10.10.10.252:600 REQUEST_URI=/  strace -t -f  -s 600  /usr/local/php/bin/php  backend/web/index.php  2>&1  | grep /config

直接就可以输出出来所有的配置文件:

我的日志:

[root@grande erp]# HTTP_HOST=10.10.10.252:600 REQUEST_URI=/  strace -t -f  -s 600  /usr/local/php/bin/php  backend/web/index.php  2>&1  | grep /config
11:37:31 read(3, "<?php\n//echo md5(md5('grandbest!c').'admin');\n//exit;\ndefined('YII_DEBUG') or define('YII_DEBUG', true);\ndefined('YII_ENV') or define('YII_ENV', 'dev');   // prod(YII_ENV_PROD=true) , dev(YII_ENV_DEV=true) , test(YII_ENV_TEST=true)\n//global\n\n$active_menu = \"\";\nrequire(__DIR__ . '/../../common/Func.php');\nrequire(__DIR__ . '/../../vendor/autoload.php');\nrequire(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');\nrequire(__DIR__ . '/../../common/config/bootstrap.php');\n\n$config = yii\\helpers\\ArrayHelper::merge(\n    require(__DIR__ . '/../../common/config/main.php'),\n    require(__DIR__ . '/../../co"..., 4096) = 857
11:37:31 lstat("/www/web/develop/erp/backend/web/../../common/config/bootstrap.php", {st_mode=S_IFREG|0777, st_size=659, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/web/../../common/config", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/bootstrap.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/web/../../common/config/main.php", {st_mode=S_IFREG|0777, st_size=1283, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/main.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/web/../../common/config/main-local.php", {st_mode=S_IFREG|0777, st_size=1321, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/main-local.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/web/../config/main.php", {st_mode=S_IFREG|0777, st_size=3175, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/web/../config", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 open("/www/web/develop/erp/backend/config/main.php", O_RDONLY) = 3
11:37:31 open("/www/web/develop/erp/backend/config/../../common/config/custom", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/blog.php", {st_mode=S_IFREG|0744, st_size=27, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/blog.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/cache.php", {st_mode=S_IFREG|0744, st_size=1089, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/cache.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/category.php", {st_mode=S_IFREG|0744, st_size=165, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/category.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/cookie.php", {st_mode=S_IFREG|0744, st_size=158, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/cookie.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/country.php", {st_mode=S_IFREG|0744, st_size=58, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/country.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/currency.php", {st_mode=S_IFREG|0744, st_size=658, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/currency.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/customer.php", {st_mode=S_IFREG|0744, st_size=521, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/customer.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/email.php", {st_mode=S_IFREG|0744, st_size=806, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/email.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/home.php", {st_mode=S_IFREG|0744, st_size=134, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/home.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/payment.php", {st_mode=S_IFREG|0744, st_size=1647, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/payment.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/product.php", {st_mode=S_IFREG|0744, st_size=4286, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/product.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/shipping.php", {st_mode=S_IFREG|0744, st_size=297, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/shipping.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/store.php", {st_mode=S_IFREG|0744, st_size=749, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/store.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/custom/url.php", {st_mode=S_IFREG|0744, st_size=423, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/custom/url.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/params.php", {st_mode=S_IFREG|0777, st_size=61, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/params.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../common/config/params-local.php", {st_mode=S_IFREG|0777, st_size=161, ...}) = 0
11:37:31 open("/www/web/develop/erp/common/config/params-local.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/params.php", {st_mode=S_IFREG|0777, st_size=460, ...}) = 0
11:37:31 open("/www/web/develop/erp/backend/config/params.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/params-local.php", {st_mode=S_IFREG|0777, st_size=18, ...}) = 0
11:37:31 open("/www/web/develop/erp/backend/config/params-local.php", O_RDONLY) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/menu.php", {st_mode=S_IFREG|0777, st_size=11502, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/local.php", {st_mode=S_IFREG|0777, st_size=797, ...}) = 0
11:37:31 open("/www/web/develop/erp/backend/config/../../myapp/etc/mongo", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/admin_user.php", {st_mode=S_IFREG|0777, st_size=295, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/base_catalog_category.php", {st_mode=S_IFREG|0744, st_size=505, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/base_catalog_category_product.php", {st_mode=S_IFREG|0744, st_size=328, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/base_catalog_product.php", {st_mode=S_IFREG|0744, st_size=764, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/ids.php", {st_mode=S_IFREG|0744, st_size=352, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/order_email.php", {st_mode=S_IFREG|0777, st_size=1171, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/sync_from_onfancy_log.php", {st_mode=S_IFREG|0744, st_size=355, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/web_catalog_category.php", {st_mode=S_IFREG|0744, st_size=2208, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/web_catalog_category_product.php", {st_mode=S_IFREG|0744, st_size=1302, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/web_catalog_product.php", {st_mode=S_IFREG|0744, st_size=2641, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/web_category_link_base_category.php", {st_mode=S_IFREG|0744, st_size=397, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/web_site_body.php", {st_mode=S_IFREG|0744, st_size=272, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/mongo/web_site_update_log.php", {st_mode=S_IFREG|0744, st_size=384, ...}) = 0
11:37:31 open("/www/web/develop/erp/backend/config/../../myapp/etc/modules", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Ebay_Ebayorder.php", {st_mode=S_IFREG|0666, st_size=117, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Adminlogin.php", {st_mode=S_IFREG|0777, st_size=110, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Customer.php", {st_mode=S_IFREG|0777, st_size=106, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Dashboard.php", {st_mode=S_IFREG|0777, st_size=108, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Erpproduct.php", {st_mode=S_IFREG|0744, st_size=132, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Product.php", {st_mode=S_IFREG|0777, st_size=104, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Purchase.php", {st_mode=S_IFREG|0777, st_size=106, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Resource.php", {st_mode=S_IFREG|0777, st_size=106, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Sales.php", {st_mode=S_IFREG|0777, st_size=100, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_System.php", {st_mode=S_IFREG|0777, st_size=102, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_User.php", {st_mode=S_IFREG|0744, st_size=98, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Wish.php", {st_mode=S_IFREG|0777, st_size=106, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Erp_Xxapi.php", {st_mode=S_IFREG|0777, st_size=100, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/config/../../myapp/etc/modules/Wish_Wishorder.php", {st_mode=S_IFREG|0777, st_size=117, ...}) = 0
11:37:31 lstat("/www/web/develop/erp/backend/web/../config/main-local.php", {st_mode=S_IFREG|0777, st_size=757, ...}) = 0
11:37:31 open("/www/web/develop/erp/backend/config/main-local.php", O_RDONLY) = 3
11:37:32 access("/www/web/develop/erp/myapp/code/core/Erp/Adminlogin/etc/config.php", F_OK) = -1 ENOENT (No such file or directory)


这篇关于Strace 追踪 php 模拟页面执行,打印log的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/844966

相关文章

golang 日志log与logrus示例详解

《golang日志log与logrus示例详解》log是Go语言标准库中一个简单的日志库,本文给大家介绍golang日志log与logrus示例详解,感兴趣的朋友一起看看吧... 目录一、Go 标准库 log 详解1. 功能特点2. 常用函数3. 示例代码4. 优势和局限二、第三方库 logrus 详解1.

Spring定时任务只执行一次的原因分析与解决方案

《Spring定时任务只执行一次的原因分析与解决方案》在使用Spring的@Scheduled定时任务时,你是否遇到过任务只执行一次,后续不再触发的情况?这种情况可能由多种原因导致,如未启用调度、线程... 目录1. 问题背景2. Spring定时任务的基本用法3. 为什么定时任务只执行一次?3.1 未启用

Android WebView无法加载H5页面的常见问题和解决方法

《AndroidWebView无法加载H5页面的常见问题和解决方法》AndroidWebView是一种视图组件,使得Android应用能够显示网页内容,它基于Chromium,具备现代浏览器的许多功... 目录1. WebView 简介2. 常见问题3. 网络权限设置4. 启用 JavaScript5. D

CSS模拟 html 的 title 属性(鼠标悬浮显示提示文字效果)

《CSS模拟html的title属性(鼠标悬浮显示提示文字效果)》:本文主要介绍了如何使用CSS模拟HTML的title属性,通过鼠标悬浮显示提示文字效果,通过设置`.tipBox`和`.tipBox.tipContent`的样式,实现了提示内容的隐藏和显示,详细内容请阅读本文,希望能对你有所帮助... 效

Flutter监听当前页面可见与隐藏状态的代码详解

《Flutter监听当前页面可见与隐藏状态的代码详解》文章介绍了如何在Flutter中使用路由观察者来监听应用进入前台或后台状态以及页面的显示和隐藏,并通过代码示例讲解的非常详细,需要的朋友可以参考下... flutter 可以监听 app 进入前台还是后台状态,也可以监听当http://www.cppcn

grom设置全局日志实现执行并打印sql语句

《grom设置全局日志实现执行并打印sql语句》本文主要介绍了grom设置全局日志实现执行并打印sql语句,包括设置日志级别、实现自定义Logger接口以及如何使用GORM的默认logger,通过这些... 目录gorm中的自定义日志gorm中日志的其他操作日志级别Debug自定义 Loggergorm中的

MySQL表锁、页面锁和行锁的作用及其优缺点对比分析

《MySQL表锁、页面锁和行锁的作用及其优缺点对比分析》MySQL中的表锁、页面锁和行锁各有特点,适用于不同的场景,表锁锁定整个表,适用于批量操作和MyISAM存储引擎,页面锁锁定数据页,适用于旧版本... 目录1. 表锁(Table Lock)2. 页面锁(Page Lock)3. 行锁(Row Lock

SpringBoot项目注入 traceId 追踪整个请求的日志链路(过程详解)

《SpringBoot项目注入traceId追踪整个请求的日志链路(过程详解)》本文介绍了如何在单体SpringBoot项目中通过手动实现过滤器或拦截器来注入traceId,以追踪整个请求的日志链... SpringBoot项目注入 traceId 来追踪整个请求的日志链路,有了 traceId, 我们在排

禁止HTML页面滚动的操作方法

《禁止HTML页面滚动的操作方法》:本文主要介绍了三种禁止HTML页面滚动的方法:通过CSS的overflow属性、使用JavaScript的滚动事件监听器以及使用CSS的position:fixed属性,每种方法都有其适用场景和优缺点,详细内容请阅读本文,希望能对你有所帮助... 在前端开发中,禁止htm

JavaScript中的reduce方法执行过程、使用场景及进阶用法

《JavaScript中的reduce方法执行过程、使用场景及进阶用法》:本文主要介绍JavaScript中的reduce方法执行过程、使用场景及进阶用法的相关资料,reduce是JavaScri... 目录1. 什么是reduce2. reduce语法2.1 语法2.2 参数说明3. reduce执行过程