LOGGING In ASP Net Core 2 0 LOGGING

  • Slides: 8
Download presentation
LOGGING In ASP. Net Core 2. 0

LOGGING In ASP. Net Core 2. 0

LOGGING • Your program (web app) will run on a server, 24 x 7,

LOGGING • Your program (web app) will run on a server, 24 x 7, forever and ever • If something goes wrong you want to get useful info about what happened • You may not be able to attach the debugger to the web app • You may not be able to reproduce the problem • Logging: • Saving messages for later reference, in order to help you figure out what your program is doing wrong / underperforming / how that hacker broke into your system / etc

TUTORIAL • We’ll be walking through: • https: //docs. microsoft. com/en-us/aspnet/core/fundamentals/logging/? view=aspnetcore 2. 1&tabs=aspnetcore

TUTORIAL • We’ll be walking through: • https: //docs. microsoft. com/en-us/aspnet/core/fundamentals/logging/? view=aspnetcore 2. 1&tabs=aspnetcore 2 x

PROVIDERS • “A logging provider takes some action on logged data, such as display

PROVIDERS • “A logging provider takes some action on logged data, such as display it on the console or store it in Azure blob storage. ” • Examples of providers: • • Print it to the console (just like Console. Write. Line) Save it to a file Save it to a database Save it to Azure (aka “save it to a file/database in the cloud”) • Built-in providers: • https: //docs. microsoft. com/en-us/aspnet/core/fundamentals/logging/? view=aspnetcore 2. 1&tabs=aspnetcore 2 x#built-in-logging-providers • You can also use 3 rd party providers (your own, or written by someone else)

PROVIDERS • Let’s add in the Console & Debugger providers, as per that first

PROVIDERS • Let’s add in the Console & Debugger providers, as per that first step in the tutorial

ADDING ITEMS TO THE LOG(S) • <Let’s look a the sample code in “How

ADDING ITEMS TO THE LOG(S) • <Let’s look a the sample code in “How to create logs”> • Let’s go through “Sample logging output”

ADDING ITEMS TO THE LOG(S) • Categories • So you know where the message

ADDING ITEMS TO THE LOG(S) • Categories • So you know where the message is coming from • Log Level • You can specify how important it is to see the message • You can then tell the logger what level (and above) you want to see • This way you can put a ton of messages in at the ‘Debug’ (lowest) level, set the level to display higher for day-to-day use, and only see critical messages normally. Once you know there’s a bug you can change the log level to be ‘debug’ to get detailed information (for debugging purposes) • This is covered in the “Log filtering” section

LET’S ADD LOGGING TO YOUR APP

LET’S ADD LOGGING TO YOUR APP