如何在 Visual Studio 代码中为语言服务器启用日志
How to enable logs for Language server in Visual Studio Code
在 Language Server Extension Guide 中说:
'If you are using vscode-languageclient
to implement the client, you
can specify a setting [langId].trace.server
that instructs the Client
to log communications between Language Client / Server to a channel of
the Language Client's name
.
For lsp-sample, you can set this setting:
"languageServerExample.trace.server": "verbose"
. Now head to the
channel "Language Server Example". You should see the logs:
我在 VS Code 中的何处以及如何具体指定此设置?
我为 php 语言服务器所做的是将 "log": true
添加到 launch.json 文件,然后编译器将尝试显示日志您按 f5 开始调试。但是据我从您在问题中分享的文档中了解到,您可以按照此说明进行操作(我不保证这会起作用,正如我提到的,这是 you 的说明已分享您的问题):
- 按Ctrl+逗号。
- 搜索 "trace server".
- 现在应该列出语言。如果您使用的是最新版本的 vscode,请在您想要的任何语言服务器中选择详细。
- 如果您使用的是旧版本 vscode,请选择所需语言旁边的铅笔按钮,然后 select "verbose".
在新打开的名为 [Extension Development Host]
的 VS Code 实例的工作区设置中更改它,而不是原来的 VS Code。
您还可以更改 package.json:
中的默认值
"languageServerExample.trace.server": {
"scope": "window",
"type": "string",
"enum": ["off","messages","verbose"],
"default": "verbose",
找到了!
您需要在 launch.json
.
中创建一个新的 Node.js Attach 运行 配置
{
"name": "Attach",
"port": 6009,
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
并将 port
从默认 9229
更改为 6009
。在实例化new LanguageClient()
:
的时候也需要在ServerOptions
中传递这个6009端口
之后,当您使用 F5 启动插件时,您现在可以转到 运行 视图和 运行 新创建的“附加”与您的客户端进程一起配置:
当两个进程都在 运行ning 时,您可以在 Call Stack 部分中在它们之间切换以查看您的客户端 console.log
或您的语言服务器的:
发布赏金后,当然,一如既往...
在 Language Server Extension Guide 中说:
'If you are using
vscode-languageclient
to implement the client, you can specify a setting[langId].trace.server
that instructs the Client to log communications between Language Client / Server to a channel of the Language Client'sname
.For lsp-sample, you can set this setting:
"languageServerExample.trace.server": "verbose"
. Now head to the channel "Language Server Example". You should see the logs:
我在 VS Code 中的何处以及如何具体指定此设置?
我为 php 语言服务器所做的是将 "log": true
添加到 launch.json 文件,然后编译器将尝试显示日志您按 f5 开始调试。但是据我从您在问题中分享的文档中了解到,您可以按照此说明进行操作(我不保证这会起作用,正如我提到的,这是 you 的说明已分享您的问题):
- 按Ctrl+逗号。
- 搜索 "trace server".
- 现在应该列出语言。如果您使用的是最新版本的 vscode,请在您想要的任何语言服务器中选择详细。
- 如果您使用的是旧版本 vscode,请选择所需语言旁边的铅笔按钮,然后 select "verbose".
在新打开的名为 [Extension Development Host]
的 VS Code 实例的工作区设置中更改它,而不是原来的 VS Code。
您还可以更改 package.json:
中的默认值"languageServerExample.trace.server": {
"scope": "window",
"type": "string",
"enum": ["off","messages","verbose"],
"default": "verbose",
找到了!
您需要在 launch.json
.
{
"name": "Attach",
"port": 6009,
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
并将 port
从默认 9229
更改为 6009
。在实例化new LanguageClient()
:
ServerOptions
中传递这个6009端口
之后,当您使用 F5 启动插件时,您现在可以转到 运行 视图和 运行 新创建的“附加”与您的客户端进程一起配置:
当两个进程都在 运行ning 时,您可以在 Call Stack 部分中在它们之间切换以查看您的客户端 console.log
或您的语言服务器的:
发布赏金后,当然,一如既往...