doubeng9407 2017-02-23 14:10
浏览 114
已采纳

php.ini使用xdebug.log的当前日期设置动态文件夹路径

So my problem is that my xdebug.log file is too big and so I was thinking of splitting it by one file a day. I know how to do that manually, but I'd like to know if it was possible to set a dynamic path to a new xdebug file through php.ini as it is where the path is defined. currently I have this:

php.ini
xdebug.remote_log="D:\Work\Project\www\xdebug.log"

and I'd like to end up with something like this:

php.ini
xdebug.remote_log="D:\Work\Project\www\2017\02\23_xdebug.log"

I do know that there is a possibility to use some variable (I did read the php doc, google after it for severals hours) but I can't really find a clear answer so far about if I can do this, have a workaround or just how to do it!

Thanks in advance!! (if I missed some information to provide just tell me!)

  • 写回答

1条回答 默认 最新

  • dongyixiu3110 2018-02-13 09:43
    关注

    Just simply went through this with the script solution in the end, using powershell.

    Here you can see the function (you can directly add it in your Microsoft.Powershell_profile.ps1 (more info about how to create one here : 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
    }
    

    After adding it to your profile, simply restart your powershell prompt and type xdebugsetlogpath and that it! (don't forget to edit the path where you want to get your logs in!)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧