所以我的问题是我的xdebug.log文件太大了,所以我想把它每天分成一个文件。 我知道如何手动执行此操作,但我想知道是否可以通过php.ini设置新的xdebug文件的动态路径,因为它是定义路径的位置。 目前我有这个:
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文档,google后几个小时)但到目前为止我还无法找到一个明确的答案,如果我能做到这一点,有解决方法或只是如何做到这一点!
提前致谢!! (如果我错过了一些信息,请告诉我!)
答案 0 :(得分:0)
最后使用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
即可! (不要忘记编辑您希望登录的路径!)