Preventing Log Category from being logged in Microsoft.Extensions.Logging SimpleConsole logs

981 Views Asked by At

I have added logging to two projects (.net-5 and .net-6) using Microsoft.Extensions.Logging SimpleConsole as below:

services.AddLogging(builder => builder
                                .AddSimpleConsole(options =>
                                {
                                    options.IncludeScopes = true;
                                    options.SingleLine = true;
                                    options.TimestampFormat = "yyyy-MM-dd hh:mm:ss ";
                                }));

But when I log my own messages using:

_logger.LogInformation($"customer: {selectedCustomer.Name}");

the section following "info:" contains the Log Category in front of the message I want to log.

2022-01-05 10:13:17 info: MySite.Pages.Customers[0] customer: admin

The messages I log can be long, and I would still like to see them on one line that fits into the screen. Therefore, how can I get rid of the Log Category, so it it logs only my message?

0

There are 0 best solutions below