Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write to log from vscode extension?

I am attempting to develop an extension with a language-server for VSCode. I am trying to figure out how to write text to log from language-server part of the extension. console.log produces nothing

like image 758
hinst Avatar asked Dec 04 '15 09:12

hinst


People also ask

How do you find logs in VS Code?

To open the Log Viewer, open the command palette (press Ctrl / Cmd + Shift + P or click View > Command Palette) and then run Cloud Code: View Logs.


Video Answer


2 Answers

Just as an update, you can use vscode.window.createOutputChannel to create the output container and then write to it with the appendLine method.

    //Create output channel     let orange = vscode.window.createOutputChannel("Orange");      //Write to output.     orange.appendLine("I am a banana."); 

Results of creating output channel.

like image 146
Alex Avatar answered Sep 27 '22 19:09

Alex


You have to set an outputChannelName property on the client options inside the client extension code:

let clientOptions: LanguageClientOptions = {   outputChannelName: 'XYZ Language Server', }; 

Once you've done that you can use console.log() and it will be shown in the VSCode extension output panel.

like image 42
TBieniek Avatar answered Sep 27 '22 19:09

TBieniek