php - How to have XDebug send log entries to VS Code 'Debug console' window? - Stack Overflow

admin2025-05-01  1

I am developing a PHP application hosted on Apache installed through XAMPP 3.3, on Windows. I have the XDebug 3.x extension set up in VS Code and debugging works perfectly fine. My launch.json entry looks like this:

    {
        "name": "Listen for Xdebug",
        "type": "php",
        "request": "launch",
        "port": 9003
    },

My Apache php.ini looks like this:

[...]
error_log="C:\xampp\php\logs\php_error_log.log"
[...]

[XDebug]
zend_extension=xdebug
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.client_host=192.168.1.10
xdebug.client_port=9003
xdebug.log=C:\xampp\apache\logs\xdebug.log
xdebug.log_level=7

I see that xdebug.log is successfully used by XDebug. I don't see any obvious error in this file.

In my PHP script, I can successfully create a log entry by using error_log('This is a log entry'), and this string gets appended to php_error_log.log, as expected.

However, I don't know how to have XDebug send over the log entries to the DEBUG CONSOLE pane window in Visual Studio Code. Is it possible?

I am developing a PHP application hosted on Apache installed through XAMPP 3.3, on Windows. I have the XDebug 3.x extension set up in VS Code and debugging works perfectly fine. My launch.json entry looks like this:

    {
        "name": "Listen for Xdebug",
        "type": "php",
        "request": "launch",
        "port": 9003
    },

My Apache php.ini looks like this:

[...]
error_log="C:\xampp\php\logs\php_error_log.log"
[...]

[XDebug]
zend_extension=xdebug
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.client_host=192.168.1.10
xdebug.client_port=9003
xdebug.log=C:\xampp\apache\logs\xdebug.log
xdebug.log_level=7

I see that xdebug.log is successfully used by XDebug. I don't see any obvious error in this file.

In my PHP script, I can successfully create a log entry by using error_log('This is a log entry'), and this string gets appended to php_error_log.log, as expected.

However, I don't know how to have XDebug send over the log entries to the DEBUG CONSOLE pane window in Visual Studio Code. Is it possible?

Share Improve this question asked Jan 2 at 17:32 andynewmanandynewman 3451 silver badge10 bronze badges 1
  • I think that if you set your PHP error_log setting to syslog and PHP will send all error log messages to stderr, which Xdebug will then send to the IDE. – Derick Commented Jan 10 at 10:50
Add a comment  | 

1 Answer 1

Reset to default 0

If you set your PHP error_log setting to syslog and PHP will send all error log messages to stderr, which Xdebug will then send to the IDE.

Xdebug itself does not send error_log messages to the IDE, but there is now an xdebug_notify() function, with which you can send messages (strings, and variables) to the IDE as well.

转载请注明原文地址:http://www.anycun.com/QandA/1746104942a91737.html