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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器