I'm trying to print a log message in ASP.NET Core this way:
Console.WriteLine( "Hello World!" );
loggerFactory.MinimumLevel = LogLevel.Debug;
loggerFactory.AddConsole( LogLevel.Debug );
var logger = loggerFactory.CreateLogger("Startup");
logger.LogWarning( "Hi!" );
Where can I see this message?
The Output window doesn't contain this message.
If I run the project as Web, it runs the dnx
console where I can see the message, but it is not convenient.
If I run project as IIS Express I don't see the console, or the message.
Is there way to view the message in Visual Studio?
Logging libraries like Nlog NET is Nlog. After you add the NLog library to your project, you need to instantiate the class and log your events based on the error level. Logger logger = LogManager. GetLogger("console"); logger.
\%home%\LogFiles\stdout .
You can use the Debug
listener to achieve what you want:
"dependencies": {
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
}
Console.WriteLine( "Hello World!" );
loggerFactory.MinimumLevel = LogLevel.Debug;
loggerFactory.AddDebug( LogLevel.Debug );
var logger = loggerFactory.CreateLogger("Startup");
logger.LogWarning( "Hi!" );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With