iamkinetic / NEventSocket

A reactive FreeSwitch eventsocket library for .Net/.Net Framework (.net standard 2)
Mozilla Public License 2.0
26 stars 11 forks source link

Value cannot be null. (Parameter 'factory') #5

Closed panicou closed 3 years ago

panicou commented 3 years ago

I created a simple program and got Value cannot be null. (Parameter 'factory') from Microsoft.Extensions.Logging.Abstractions

code as follows :

using System; using System.Reactive.Linq; using System.Threading.Tasks; using NEventSocket; using NEventSocket.FreeSwitch;

namespace ConsoleApp1 { class Program { static async Task Main(string[] args) { await CallTracking();

        Console.WriteLine("Hello World!");
    }

    public static async Task CallTracking()
    {
        using (var socket = await InboundSocket.Connect("XXX.XXX.XXX.XXX", 8021, "ClueCon"))
        {
            var apiResponse = await socket.SendApi("status");
            Console.WriteLine(apiResponse.BodyText);

            //Tell FreeSwitch which events we are interested in
            await socket.SubscribeEvents(EventName.ChannelAnswer);

            //Handle events as they come in using Rx
            socket.ChannelEvents.Where(x => x.EventName == EventName.ChannelAnswer)
                  .Subscribe(async x =>
                  {
                      Console.WriteLine("Channel Answer Event " + x.UUID);

                      //we have a channel id, now we can control it
                      await socket.Play(x.UUID, "misc/8000/misc-freeswitch_is_state_of_the_art.wav");
                  });
        }
    }
}

}

any ideas ??

i am using .net core 3.1

lilunxm12 commented 3 years ago

Add NEventSocket.Logging.Logger.Configure(new LoggerFactory()); before your initialize any NEventSocket class

panicou commented 3 years ago

thx that solved it.

samuelting commented 2 years ago

This error message reminds you of specifying loggers used by NEventSocket Library. If you want to log NEventSocket with your logger, you may need to consider adding this in ConfigureServices method in the StartUp.cs in your .NET core application.

NEventSocket.Logging.Logger.Configure(LoggerFactory.Create(builder => {
                builder
                .AddConsole();
            }));