Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nest 2.0 enable trace

Tags:

nest

I am on updating to the latest Nest version. Since I am getting not the expected results I am searching for replacement of the EnableTrace() method which was a method of ConnectionSettings on previous versions.

like image 934
core Avatar asked Feb 22 '16 13:02

core


1 Answers

EnableTrace() will be back, but it's not available yet(have a look).

For now you can use this code to print out information about request and response:

var settings = new ConnectionSettings(connectionPool)
    .DefaultIndex(indexName)
    .DisableDirectStreaming()
    .OnRequestCompleted(details =>
    {
        Debug.WriteLine("### ES REQEUST ###");
        if(details.RequestBodyInBytes != null) Debug.WriteLine(Encoding.UTF8.GetString(details.RequestBodyInBytes));
        Debug.WriteLine("### ES RESPONSE ###");
        if (details.ResponseBodyInBytes != null) Debug.WriteLine(Encoding.UTF8.GetString(details.ResponseBodyInBytes)); 
    })
    .PrettyJson();

Make sure you have set .DisableDirectStreaming() on ConnectionSettings.

Hope it helps.

like image 139
Rob Avatar answered Nov 07 '22 03:11

Rob