In this video tutorial, we'll compare ChatGPT and Copilot for integrating Serilog into our ASP NET Core application. Which one of these tools can do a better job with the integration?
View Transcript
Interesting, right? This is something that I did not say to chat GPT. I didn't even tell that to co-pilot. In this video, we're going to look at adding Sarah log logging to an ASP.NET Core application. But unlike the previous video that I did on this, which you if you haven't watched, you can check out right up here. We're going to ask C-Pilot and ChatgPT to go build this functionality for us. And the reason that I wanted to make this video was to show you that now that if you're getting stuck on programming issues or challenges, you're trying to integrate something that we have a lot of really helpful tools and they might behave a little bit differently. So, it's not just like a, you know, super simple thing if you're not used to doing this. But if you experiment and play around and try out
the different tools, you can see how to basically get yourself unblocked. And I'm not trying to put myself out of business here on YouTube because I'd love if you come back and watch my videos, but I figured I'll show you this kind of stuff because if you're not familiar with doing it yet, this might be a good little unblocker for yourself. So, in the previous video, we looked at getting ASP.NET Core set up with Sarah log. And one of the things that we were talking about was reading in the configuration from app settings JSON. So, what I'm going to do is go to chat GPT. We're going to start with chat evbt and then we'll use co-pilot inside of visual studio. But I already have a little sample project for us to work with. All that I did was made a new project in Visual
Studio. I haven't hooked up any Sarah log stuff to this yet. There's no nougat packages added. I just wanted to show you that I have it. We'll go to chatpt first and then we'll ask C-Pilot to basically do the same thing for us. And we're going to compare what these two experiences look like. And it's not that I'm trying to say that one is right or one is wrong or one's always better, one's always worse, but these are just different tools. Okay, so the first thing is we're going to go to chatgpt and just say let me see if I can talk like this. Excellent. Okay, so I'm just going to type in my or I'm going to speak my prompt. I have an ASP.NET Core application and I would like to add Serogg to it. I need to make sure that I can load
the serial log configuration from app settings JSON and I would like to configure it this way instead of in code for all of the different settings for Serillog. This is in a nutshell what I'm trying to accomplish. Now, if you're more experienced with doing this kind of thing, you might say, "Hey, Nick, that's not enough detail for it to do maybe what you want. We didn't ask it what Nougat packages we need. We didn't say exactly what's going on, the shape or the structure of our project. It doesn't know that I'm dealing with the sample weather application, right? It doesn't have all of this context, but maybe that's okay for what we're trying to do. This is really what we're trying to accomplish. Chat GPT is spitting back some stuff for us. I just realized this is uh Chat GPD 5.1 instant. I don't think
I've used this model yet. Literally started recording this video and just noticed that. So we can see it has three Nougat packages. Interestingly enough, these are the packages I believe that I use in my previous video. The versions might be different. So that's something interesting to think about. I didn't tell it what version ofNNET. I also didn't tell you what version of .NET 10 is out at the time that I'm recording this. So this project is withNET 10. Maybe these will work, maybe they won't. We'll have to see. But we're just going to do what chatgptt tells us to and drop in some of this stuff. Then you can see that it has an app settings JSON file we're going to be using. It says this is the console writer and I notice up here we have the console sync. Okay, it has a template
for us. It has enrichment. We didn't ask for it. This is funny because it's clearly using some context from my other chats. This is a brand new chat. You saw me start this. It's referencing brand ghost which is an application that I build on the side in this chat. I've never given it any such context. So kind of interesting. Let's keep going. Then it says to modify a program.cs file so far. Okay, it's kind of interesting. So it does have a bootstrap logger. This is not something we asked for, but if you've watched the previous video, I mentioned that if you wanted to log outside of our minimal API, again, this doesn't actually know that we're dealing with the minimal API from the sample weather app. If you want to log outside of that, we need a bootstrap logger to be able to do that.
We can see down here that it's also doing enrichment from log context, read from services, but in the previous video, we basically only really need this line to get things going. Okay. Okay. And then it has at the end this close and flush. We didn't even use that in the previous video, but we have some examples to work with. So, let's start copying this stuff over and see if it works in Visual Studio based on using what chat GPT suggests with a very simple prompt. Let's start with the Nougat packages. So, these in here, I'm just going to drop in that. Okay. So, my camera's in the way. Sorry. Here we go. So, now I have these three packages added. We're going to get the app settings JSON file copied over. This says add your serial lock configuration app settings JSON. It didn't say anything
about app settings.development.json or production or anything else. So we'll go over to app settings. Now if we just follow along with it, we could just drop it here. That's what it said to do. It didn't say anything about app settings development. So let's see if that works for us. And then I'm going to be a little bit pickier here with what I'm taking. So we're going to take these pieces. Okay. And it added the using statement for me. And then I'm going to take this last part for the close and flush. If we go back to chat GPT, it had a little bit more detail. So it was saying if we want to use an I logger. One of the things that I got caught off guard with in the previous video was that it's using a typed logger. By default, it's not going to
just assign Sarah log for an ey logger. You have to do a little bit more. And so that wasn't working. But with a typed logger, it did work. So, if we want to use that in a minimal API, this is what we need. And now it's saying down here, okay, if I read a little bit further, right, optional ad environment specific logging overrides. Let's do that. We go in here and we're going to add this into our app settings development. So, this is really like vibe coding because I'm just trying out what it says. But we do need to add in our Oh, it put weather forecast in a different file. And I just realized now that it was using a controller. So, I picked the wrong template and I wasn't paying attention right before I made this video, but that's okay. So, I'm going
to do this where I take in an ey logger. Sorry, I thought that I was using a minimal API and I was wrong, but that's okay. It's not going to make a huge difference here. So, there is my primary constructor that will at least anger one person because not everyone likes these. I'm just going to put this in here. Logger debug generating weather forecast. And that way we have a log line. If you're using a minimal API, I would have expected that in program.cs we had that added in here when it's doing the configuration. You can essentially put your logger, your typed logger directly in the minimal API arguments. So we do have that ability. This is just using a controller. Same idea. I'm just adding it to the public constructor. We could instead go put it onto here. Let's go ahead and run this
and see what happens. Okay. To kick things off, we have the application running. If you don't hook up Sarah log, generally when you start an ASP on a core app, you end up having some logs come out. But if you're familiar with hooking up Sarah log or some other loggers, it's hiding this startup logging that we usually see. And that's because we would essentially be using, if I go back to program.cs, this bootstrap logger. So, we've kind of hijacked what's going on. This is what happened in the previous video as well. So, if you wanted some other logging during startup, you can use this bootstrap logger before your web API is hit. What I've done now is I've gone back to the browser. I just had to go look up what port it was running on. And if we make a get call to the
weather forecast API, we do get this in the browser. So, this method worked. It's not like everything crapped out on us. And if I go back to here, we can see that we do have the logger line being hit and getting logs out to here. and generating weather forecast. So, chat GPT did do what we needed to do, right? We asked a very basic question. We said, how do we go hook this up, copied the code over and we essentially vibe coded getting Sarah log wired up in an ASP. Core app with app settings, but can we do the same thing with C-Pilot? And does it just do a better job? Is it easier? Let's go compare what that looks like. And again, my goal here is not to tell you one is better or worse. Personally, when I'm just chatting back and forth, I
actually prefer using chat GPT. And sometimes that means I have to go give it a little bit of extra context. I have to go out of my way to say, "Hey, by the way, I'm building in this. Here's some examples of stuff because it can't see the code that I have. If I'm in C-Pilot, it has all of that other context." But sometimes just the, you know, the UX, like how I'm interacting just doesn't feel as good in some situations. So, I go back and forth, but I have to think about what tool I'm using and how that might behave differently. Okay, I've just gone through and essentially got rid of all of the code that we copied over from Chat GPT. I'm going to use Copilot now and I'm going to give it, let's see, maybe the same prompt. Maybe not the exact same.
If I go back over to chat GPT, let's just put this into Copilot to start. I might not press enter on it yet because I want to think about what I'm going to be doing here because I do have some other projects in the solution. Um, it might know based on the active document that I have open what I'm expecting. I just want to think about this before we press enter. So I am saying to it I have an ASP on a core application. It already knows that right based on the context. I would like to add Sarah log to it. I need to make sure that I can load the serial log configuration from app settings. I'm also reading this right now. when I spoke it out, it formatted this kind of funny. That's obviously not the exact right thing, but Tachbt figured it
out. Um, and I would like to configure this uh it this way instead of in code for all the different settings of Serlock. Okay, I feel like this should work. If we notice that it's going and touching the other projects in the solution, we'll go stop it. But that might be one thing that I would say like explicitly for this project. But otherwise, let's just try it out and see what it does. I'm curious to see. I expect that it will pick different package versions because it will know that we're using .NET 10. I don't know this for a fact. I'm just making an assumption that this is one of the differences I might expect to see. It's reading app settings JSON. It's going and reading the development JSON. It did pick the right project. So again, is that luck or is that because it
was using the active uh file to to go figure that out? Okay, I have to go approve these. Always allow one more. I have just installed Visual Studio 2026, which is what you're seeing right now. It's using insiders before. So, some of the things the settings didn't carry over exactly. That's fine. We'll approve it once. Now, it says reading four projects. I don't want it to go touch the other project. So, I'm a little bit nervous about that, but that's okay. That's why I said I might want to be more specific, but we'll see what it does. Okay. Planned changes. Add seralog package references to vibe code serialog aspnet core project. That's the one we're in. That's good. Update program.cs. Excellent. Add. Oh, it says enable request logging. So interesting, right? This is something that I did not say to chat GPT. I didn't even
tell that to copilot, but it's adding request logging. Right. So adds middleware for streamline request logging. Instead of uh writing HTTP request information like method path, timing, blah blah blah, it just decided it should do that. Now, is that what we want? This is why I was saying a little bit earlier that is like co-pilot better than chat GPT in this case. Not necessarily. I might not have wanted this. It went ahead and did it anyway. I think it's pretty neat. But if you think if you kind of extrapolate this, if it's just doing other stuff that you're not asking for, you may not want that at all. Another thing to note, small detail, how it formatted this is different, right? So this is uh using this delegate syntax with the arrow, right? Whereas the other one was uh wrapping it in a method like
a body with curly braces. But overall, I think that's okay. App settings here quite similar. It enriched with different parameters. I don't know if you recall what the other one had. I'm just putting it onto my clipboard and pasting it here. But let's scroll a little bit lower. This one in China said enrich from log context with machine name with thread ID. Copilot decided from log context, thread ID, machine name, process ID, and process name. So just more and I wanted to check the versions, right? So 8, 8, and five. If we go over to the project file, there's more here, right? So it actually added enrichers. These were missing from the other one. And it's adding 9611. So these are all later, right? So it used the context. It added this. Let's keep that. I think this is a different template as well. But
definitely the fact that it has different enrichers is I think an interesting difference. This one is also a little bit unique in that in the development JSON it actually this looks like it's overriding the actual template being used. Again, we didn't say to do that, right? We didn't say do a different template between the development and not. So, Copilot has decided it's doing these other things, which I'm not mad about, but this is just something to think about. Now, we didn't add any logging into here. So, maybe I'll go put this back, and that way we have some similarity when we go to run this, but otherwise, we should see something potentially different with the serial log request logging. So, let's go run this. Okay, I'm going to go hit the weather forecast route. Before I do that, let's see. Did it Okay, it did
um it already logged something, right? So, I just went to because I wanted to get that in the browser before I type weather forecast and it gave a 404 and it logged it, which is pretty interesting, right? Like I think that's that's helpful. You may not want that for your logging. That's totally up to you. But Copilot decided it was going to do that. That is different from chat GPT. Let's go hit this route. So, this route worked. We got something in the browser. And then if we check the logging right, this is the log line that I added. And then this one down here is again this request logging middleware. So slightly different in terms of the template that it was being used, right? Chad GBT gave a different one than Copilot. Copilot added this middleware. But the point is that couple things. There's
differences just in terms of the decisions it decided to make. It had more context in terms of picking the Nougat packages. I guess another nice thing, just small detail, right? Because I was using agent mode, it actually went and made the changes for us. It dropped them right in. Copilot also made some changes to app settings JSON and development that were different between each other. So overall, like it just did different things. Now again, my point with making this video is not to tell you, oh, like therefore C-Pilot's way better. We didn't even talk about cursor or claude or the million other tools that we have to use. I just wanted to show you that if you're getting stuck on this kind of stuff and you're like, I want to know like in this example, how do we use Sarah log from app settings in
an ASP. Core web app. Yeah, you can absolutely go to YouTube. You can check out videos. I will continue to make stuff like this. I will continue to try and answer questions and put tutorials together for people. But I wanted to show you that if you're stuck on stuff, you can absolutely play around with AI tools, ask them questions, and get them to guide you down paths. What I would highly recommend, and this is just like another takeaway from using AI tools like this, just to give you a quick example, if you're like, I don't know what the heck this is, right? Use Sarah log request logging. Or if you see in here, let's go back to app settings JSON. You're like, I don't know what enrichers are. I don't know why it added these different nougat packages. I don't know why it added like
what's a sync. Please, if you don't know what these things are, you can continue to sort of like vibe code and just do what the LLM is saying. I do think that you should pause on this stuff when it's introducing code that you don't know, don't understand, and just ask it questions, right? Do this. Flip over from agent to ask. Pick a different model if you want, whatever. You know, you play around. You can learn these tools. You can see what fits well for you. And you could say something like, I'm just going to do this, right? Copilot, add to chat. Let me actually speak to it. I don't understand what these Nougat packages are for. Could you explain what these different enrichers Nougat packages do with Sarahog? Okay, we'll send that. And the whole point that I'm trying to show you here is that
you can talk to this thing, right? Like you can say like, I don't know what this does instead of just accepting things blindly. You might get lucky for, you know, more simple things. You copy the code, it just works. You've, you know, vibe coded and it did the thing. But I think if you don't get in the habit of asking this stuff, it's just missed opportunity. Right. So I am GitHub copilot. Thank you so much GitHub copilot for letting us know. Summary of the two Serilog enrichers packages. So it's listing up both of them, right? So enrichers thread and environment adds with thread ID with machine name. Okay, might be kind of obvious when you read it out with thread name adds thread name if the current uh thread has a name why it matters, right? So helpful when diagnosing concurrency issues. Okay, so if
you're like you saw this code added and you're like maybe your first instinct is to leave it. Okay, maybe you know no harm in doing that. You get some extra code, whatever. Maybe you took it away cuz you're like that's your first in instinct. You're like I don't know what it does. I'm just going to get rid of it. Maybe if you asked it and you saw, you know, helpful for diagnosing concurrency issues, deadlocks, thread pool starvation, you might say, "Oh crap, that actually does sound pretty helpful. I didn't I didn't know that option existed." Great. Add it. Right? Like you might want to keep it. What's What's this other one do? Right. Environment username as a username domain. Okay. So why it matters? Essential for aggregating logs across machines or containers and separating environments in centralized log stores. Oh, right. So, maybe for your
use case, you're like, "Man, I'm just running this off of like like locally on my machine. I don't care." Or maybe you're like, "Yeah, I do plan on having this running across a couple of different instances in the cloud. That actually does sound like it would be super helpful." Or maybe you're like, "Maybe I want that in the future. I don't need it now, but I might as well keep it because, you know, I'm planning for the future and it seems like it's a lightweight thing because we're just adding an enricher and a configuration, you know, no other code. Excellent. But you can ask the LLM about this kind of stuff. So, overall, different tools, different ways to approach things, but I just wanted to give you some guidance around how you can start asking AI to, you know, help you navigate some of these
things if you don't understand them. So, thank you so much for watching. If there's other things that you would like to see us kind of walk through, you want examples of different, you know, things we can try to configure, just ask in the comments. I'm happy to try and make a follow-up video and we can walk through it and we can just make more videos like this and kind of guide people through this kind of stuff. So, thanks for watching and I'll see you in the next one.