13

In the Language Server Extension Guide it says:

'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:

logs

Where and how exactly do I specify this setting in VS Code?

illright
  • 3,991
  • 2
  • 29
  • 54
Itachinome
  • 380
  • 3
  • 9

4 Answers4

5

Found it!

You need to create a new Node.js Attach run configuration in your launch.json.

enter image description here

{
    "name": "Attach",
    "port": 6009,
    "request": "attach",
    "skipFiles": [
        "<node_internals>/**"
    ],
    "type": "pwa-node"
},

And change the port from default 9229 to 6009. You also need to pass this 6009 port in the ServerOptions when instantiating new LanguageClient():

enter image description here

After that, when you start your plugin with F5, you can now go to the Run view and run the newly created "Attach" configuration alongside your client process:

enter image description here

When both processes are running, you can switch between them in the Call Stack section to see either your client console.logs or your language server's:

enter image description here

Just after posting a bounty, of course, like always...

Klesun
  • 12,280
  • 5
  • 59
  • 52
2

What I do for php language server is adding "log": true to launch.json file, Then the compiler will try to show logs when you press f5 to start debugging. But from what I understand from the documentation you have shared in your question, You can follow this instructions (I don't guarantee this will work, As I mentioned this is the instruction for what you have shared in your question):

  • Press Ctrl+comma.
  • Search for "trace server".
  • Now languages should be listed. If you are on the latest version of vscode, choose verbose in any language server you want.
  • If you are on an older version of vscode, then choose the pencil button next to the language you want, and select "verbose".
amirali
  • 1,888
  • 1
  • 11
  • 32
  • 4
    Thank you very much for your help. Do you know how I can view the output of console.log() statements executed within the server? They do not seem to display in the output. – Itachinome Sep 22 '18 at 13:35
0

You can also change the default value in your package.json:

"languageServerExample.trace.server": {
                    "scope": "window",
                    "type": "string",
                    "enum": ["off","messages","verbose"],
                    "default": "verbose",
-1

Change that in the workspace setting of the newly opened VS Code instance titled [Extension Development Host], not the original VS Code.

sinoTrinity
  • 1,125
  • 2
  • 15
  • 27
  • 1
    It would be great if you could extend your answer with more specific information like: change this in the file named "blah.txt" ... Otherwise your answer will just help a reduced number of people – Alejandro González Oct 14 '21 at 12:50