Logging into Elasticsearch using Serilog and viewing logs in Kibana | .NET Core Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ส.ค. 2020
  • Become a Patreon and get source code access: / nickchapsas
    Check out my courses: dometrain.com
    Hello everybody I'm Nick and in this video I will show you how you can very easily get started with logging into Elasticsearch in your .NET core application. We won't go in depth on how Elasticsearch works and why it is a good fit for a log sink but instead I am going to show you how you can quickly use Serilog to replace Microsoft's built in logging mechanism and start pushing logs into Elasticsearch, which you can then use Kibana to view and analyse. There will be a second video coming showing some of the cool stuff that you can do in Kibana with those logs.
    Don't forget to comment, like and subscribe :)
    Social Media:
    Follow me on GitHub: bit.ly/ChapsasGitHub
    Follow me on Twitter: bit.ly/ChapsasTwitter
    Connect on LinkedIn: bit.ly/ChapsasLinkedIn
    #dotnet #elasticsearch #logging #kibana

ความคิดเห็น • 64

  • @ianf765
    @ianf765 2 ปีที่แล้ว

    Thank you - I have been trying to get started with elasticsearch logging for a while without success. This was the video where I finally got it :) Great video, and just the right level of detail to your explanations.

  • @lemurza5236
    @lemurza5236 3 ปีที่แล้ว +3

    Very nice. Excited for the full elastic search video

  • @paragsarin2177
    @paragsarin2177 3 ปีที่แล้ว +5

    I really appreciate the way you explain things, keep up the good work. thanks

  • @evilroxxx
    @evilroxxx 3 ปีที่แล้ว +29

    Nick, you can also add serilog as a default logging provider into Microsoft extensions logging. So you won’t have to change from the ms implementation of Ilogger into serilog logger and continue to record your logs in the serilog format.

    • @infotips2475
      @infotips2475 2 ปีที่แล้ว +3

      where can i get an example ?

    • @yossisternlicht21
      @yossisternlicht21 ปีที่แล้ว +5

      @@infotips2475
      Here is a minimal example in dotnet 6 Minimal API
      using Serilog;
      var builder = WebApplication.CreateBuilder(args);
      builder.Host.UseSerilog((context, config) =>
      {
      config.WriteTo.Console();
      });
      var app = builder.Build();
      app.MapGet("/", (ILogger _logger) =>
      {
      _logger.LogWarning("TEST");
      return "Hello World!";
      }
      );
      app.Run();
      You must install Serilog.AspNetCore nuget package for this to work.

  • @romanhrytskiv5598
    @romanhrytskiv5598 3 ปีที่แล้ว +3

    Thank you for this video.
    TIP: you can search trough commands history in terminal emulator with CTRL+R and then typing, way faster that up/down arrows.

  • @ahmeddan7734
    @ahmeddan7734 3 ปีที่แล้ว +1

    Thanks and great job. waiting for your next Elastic search video

  • @Pampua84
    @Pampua84 3 ปีที่แล้ว +2

    Hello, first of all congratulations for your videos, they are simple and very clear and always touch on very interesting topics, also I really like your way of explaining, you can see that you love what you do and that you do it well Today I saw this video, and it would be nice if you made one on elastic stack and how would you structure your logs (real cases) in case of using filebeat. Great, keep it up

  • @mestrestephane9087
    @mestrestephane9087 ปีที่แล้ว

    Excellent explanation. Thank you Nick.

  • @daa82
    @daa82 2 ปีที่แล้ว

    These videos are great! I am learning so much!

  • @piotrkowalski3460
    @piotrkowalski3460 3 ปีที่แล้ว +2

    log templates with custom properties are working when using ILogger interface as well

  • @emlplsn
    @emlplsn 3 ปีที่แล้ว

    Awesome video, thanks for sharing.

  • @clearlyunwell
    @clearlyunwell 3 ปีที่แล้ว +1

    This is really great, thank you for all the videos you make - please never stop making videos and remember: keep coding :)

  •  2 ปีที่แล้ว

    Nick, another perfect video
    Thank you so much!
    You're the guy!

  • @denisosipenko7413
    @denisosipenko7413 3 ปีที่แล้ว

    Thanks a lot. Really useful knowledge 👍

  • @whoiam6395
    @whoiam6395 2 ปีที่แล้ว

    So useful! Thanks 👍🏻

  • @Ajmal_Yazdani
    @Ajmal_Yazdani 3 ปีที่แล้ว

    super cool. Thanks for it.

  • @shreneekpatil220
    @shreneekpatil220 3 ปีที่แล้ว +1

    Nick, you are simply awesome, i don't it is coincident or what, your all videos are linked to my current work like. Net core, serilog, reflections, redis cache, elastic search, system. Text.Json, logger etc etc... Thanks a lot for helping in directely us to building a Product

  • @suryanarayanbaliarsingh5363
    @suryanarayanbaliarsingh5363 3 ปีที่แล้ว

    very nice. Thanks for sharing.

  • @irinamurmur
    @irinamurmur 2 ปีที่แล้ว

    Thank you! Very useful

  • @matiascasag
    @matiascasag 3 ปีที่แล้ว +4

    Awesome! Thanks!. Waiting for the Elasticsearch tuto. I have a question for you.
    Does this logging to elasticsearch have a retry in case the service is down or in case of error trying to log?

  • @ADSNGreenLife
    @ADSNGreenLife 3 ปีที่แล้ว

    really useful video!!!!!

  • @LetsLearnWithA.R
    @LetsLearnWithA.R 3 ปีที่แล้ว

    Awesome !!

  • @ricardo190988
    @ricardo190988 3 ปีที่แล้ว

    Hi Nick, thanks for the video. Are you still planning on doing a video on ElasticSearch only (or maybe OpenSearch)? That'd be awesome:)

  • @yanaraldaghestani6305
    @yanaraldaghestani6305 2 ปีที่แล้ว

    amazing man

  • @mortware
    @mortware 3 ปีที่แล้ว +3

    This is great - thank you.
    I'm really interested in trying it out myself, but I came unstuck with the docker/yaml stuff. I can't get hold of your repo as there seems to be a problem with the invite system. Can you help?

  • @benlewies8828
    @benlewies8828 3 ปีที่แล้ว

    Would be great if you would cover the NEST library as well

  • @89chiponline
    @89chiponline 3 ปีที่แล้ว

    thanks

  • @MartinHAndersen
    @MartinHAndersen 3 ปีที่แล้ว +2

    Thanks for another great video. Really learning a lot from you.
    First it's freaking awesome that you can have all that functionality with so little code, awesome.
    I would like to have Serilog to log to different devices dependent on the environment the program are running in.
    localmachine to console, TEST, QA and PROD to Elastic.
    What would be the best approach?

  • @trocomerlo
    @trocomerlo 3 ปีที่แล้ว

    Great content. Is it possible to configure a retention policy of the logs in elastic search? So like if you want to keep only the last 2 months of logs.

  • @sps014
    @sps014 3 ปีที่แล้ว

    Nick Please do a tutorial on MS Search integration.

  • @noelfrancisco5778
    @noelfrancisco5778 3 ปีที่แล้ว

    This is great tool, is it possible to replace with this tool the logging from SQL (through SQL trigger, during create, update, and delete transaction)? TIA :)

  • @darkydrone
    @darkydrone 3 ปีที่แล้ว

    Can you use that with the Serlilogs Log.Error also?

  • @pranavpandey7163
    @pranavpandey7163 2 ปีที่แล้ว

    Hi Nick, As you said you are going to create a video on Elastisearch, when you are planning to upload that?

  • @furqan-safdar
    @furqan-safdar 3 หลายเดือนก่อน

    I tried to follow the steps but finding difficulty because elasticsearch version 8 has introduced major changes perhaps. Kindly post a video complying new version to use Serilog with elasticsearch

  • @TheraPi
    @TheraPi 3 ปีที่แล้ว +1

    nice and practical tutorial. However, I'm not seeing my index pattern in Kibana. I followed the exact steps, bus used the official E-L-K docker containers

  • @UstinBelarus
    @UstinBelarus 2 ปีที่แล้ว

    in case someone faces the issue with elastic service run - add "discovery.type=single-node" to the elastic service's environment

  • @zoran123456
    @zoran123456 2 ปีที่แล้ว

    you omitted logstash, how would you refactor the code to support logstash? Thanks for the tutorial.

  • @smrsgv
    @smrsgv 2 ปีที่แล้ว

    Logging not working when i publish it to IIS, but work normally locally, there is no restriction in network, how can i solve it? maybe i missed some config for production?

  • @CRBarchager
    @CRBarchager 3 ปีที่แล้ว +4

    We're already doing this in all of our applications internally :D

    • @sunnyokoro
      @sunnyokoro 3 ปีที่แล้ว

      is it free please? Do you need to pay for any of the elastic search or Kibana?

    • @evilroxxx
      @evilroxxx 3 ปีที่แล้ว

      @@sunnyokoro it’s completely free

  • @yurimelo3404
    @yurimelo3404 2 หลายเดือนก่อน

    What are the nuigets that you used?

  • @llindeberg
    @llindeberg 3 ปีที่แล้ว +1

    Have you tried elmah.io? How does it compare?

  • @ayasaber2567
    @ayasaber2567 6 หลายเดือนก่อน

    Thanks for video, but I find the Index Pattern tab

  • @volodia9509
    @volodia9509 3 ปีที่แล้ว

    Hi. Why when using method logger.information("very bad request") or logger.error("something bad") does not display my message in kibana? I got message "request finished http 1.1 post... "
    MessageTemplate {HostingRequestFinished:l}

  • @kevinli9212
    @kevinli9212 3 ปีที่แล้ว

    Personally I reckon having the configuration all coming from appsettings is a better approach

    • @nickchapsas
      @nickchapsas  3 ปีที่แล้ว +1

      It's definitely a more convenient approach but it is also definitely not a secure one

  • @christianista
    @christianista 3 ปีที่แล้ว +1

    How can we use Elasticsearch/Serilog when API is hosted on Azure?

    • @jfpinero
      @jfpinero 3 ปีที่แล้ว

      We do AppInsights/Serilog with stuff hosted in kubernets/azure, so definitely

  • @maradasa985
    @maradasa985 ปีที่แล้ว

    Nick I am still waiting the elasticsearch video XD.

    • @nickchapsas
      @nickchapsas  ปีที่แล้ว +1

      Well, shit 😂

    • @maradasa985
      @maradasa985 ปีที่แล้ว

      Not a bad idea, keep it in mind for the future, keep doing such an excellent work, a hello from a fan from Cuba

  • @CutePoisonization
    @CutePoisonization 2 ปีที่แล้ว

    my elastic server is remotely hosted and need username and password to authenticate, where do i specify these credentials in my .net core application?

  • @aronsz
    @aronsz ปีที่แล้ว

    one container, elasticsearch doesn't work for me for some reason. It starts and runs for a bit but then stops with "ERROR: Elasticsearch exited unexpectedly".
    Nick, do you have the sourcecode available somewhere perhaps? (Although I'm pretty sure I copied correctly.)

    • @aronsz
      @aronsz ปีที่แล้ว +1

      Nevermind, I had a "too low max virtual memory" issue. To fix, run:
      > wsl -d docker-desktop
      > sysctl -w vm.max_map_count=262144
      > exit (to exit the wsl)

  • @feelingeverfine
    @feelingeverfine 2 ปีที่แล้ว

    What does this have over just using Serilog and Seq? What did Elastic and Kibana get over this?

    • @nickchapsas
      @nickchapsas  2 ปีที่แล้ว

      I've seen Seq at scale and it just doesn't play nicely.

  • @mdzakariamasud8326
    @mdzakariamasud8326 3 หลายเดือนก่อน

    how to add authentication

  • @kartheeknandini3767
    @kartheeknandini3767 3 ปีที่แล้ว +1

    Nice video. I have one question. How Kibana accessing Elastic search DB. where you have configured it

    • @nickchapsas
      @nickchapsas  3 ปีที่แล้ว +1

      That is part of the docker-compose that I'm using