Logging
Good logs make it easier to identify and debug issues with your application at runtime. Ucommerce uses the built-in logging system from ASP.NET to make it simple for you to get and store log messages.
Writing logs using ILogger<TCategoryName>
Getting started with logging in Ucommerce is easy since it uses the built-in logging APIs.
You can take a dependency on the ILogger<TCategoryName>
interface and dependency injection will inject a logger into your class.
Providers
The default Ucommerce templates don't make any changes from the default logging provider setup. We recommend that you gather logs into a central log store to make discovery and debugging production issues easier.
Examples:
EF Core queries and sensitive data
When debugging issues it can be very useful to see all the values given to, and the structure of, a query created by Entity Framework. Ucommerce makes it easy to set this up for the UcommerceDBContext
by setting the Ucommerce.Persistance.SensitiveDataLogging
option to true in your appSettings.json
file.
The option activates the following in the database context:
Log queries to the console and debug output.
If you are only interested in seeing the queries created you can set the logging level for the Microsoft.EntityFrameworkCore.Database.Command
category to Information
or lower.
This should also work in production as opposed to the above option.
Last updated
Was this helpful?