php.ini设置xdebug.log的当前日期的动态文件夹路径
问题描述:
所以我的问题是,我的xdebug.log文件太大,所以我正在考虑每天将文件分割为一个文件。 我知道如何手动执行此操作,但我想知道是否可以通过php.ini设置一个到新的xdebug文件的动态路径,因为它是定义路径的地方。 目前我有这样的:php.ini设置xdebug.log的当前日期的动态文件夹路径
php.ini
xdebug.remote_log="D:\Work\Project\www\xdebug.log"
,我想有这样的事情结束了:
php.ini
xdebug.remote_log="D:\Work\Project\www\2017\02\23_xdebug.log"
我知道有使用一些变量的可能性(我看过的PHP文档,谷歌后它几个小时),但我真的不能找到一个明确的答案,迄今有关如果我可以做到这一点,有一个解决方法或只是如何做到这一点!
在此先感谢! (如果我错过了一些信息只是告诉我!)
答
只需简单地通过脚本解决方案在最后使用powershell。
在这里你可以看到功能(你可以直接在Microsoft.Powershell_profile.ps1添加它(有关如何创建一个在这里更多的信息:https://www.howtogeek.com/50236/customizing-your-powershell-profile/)
function xdebugsetlogpath {
# Set directory logs path (year\month)
$DirPath = ("Path\To\Your\logs\" + (Get-Date -UFormat '%Y\%m'))
# Set xdebug.log file name (day_xdebug.log)
$NewFile = (Get-Date -UFormat '%d') + "_xdebug.log"
# Set full file path
$NewFilePath = ($DirPath + "\" + $NewFile)
# Create the folder beforehand as xdebug wont do it itself
New-Item -ItemType Directory -Force -Path $DirPath
# Create the file (xdebug can do it but well)
New-Item $NewFilePath
(Get-Content C:\PHP712\php.ini) | `
ForEach-Object { $_ -replace 'xdebug.remote_log=.*',('xdebug.remote_log="' + $NewFilePath + '"') } | `
Set-Content C:\PHP712\php.ini
# Don't forget to restart service
httpd -k restart
}
它添加到您的个人资料后,只需重新启动你的PowerShell提示符并输入xdebugsetlogpath
并且它!(不要忘记编辑你想要登录的路径!)
AFAIK - no - https://xdebug.org/docs/all_settings# remote_log(不提及这样的选项)。也许使用一些脚本,在当天结束时/按计划重命名当前日志。 – LazyOne
If没有解决方案,这是我会去的。但我一直希望有人知道的东西! :D(因为我是一个乐观主义者!) – MI53RE