Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.net core + IIS Express. How to view log messages?

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?

like image 960
Denis535 Avatar asked May 08 '16 18:05

Denis535


People also ask

How do I check .NET logs?

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.

Where is the asp net core module stdout log?

\%home%\LogFiles\stdout .


1 Answers

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!" );
like image 85
Kévin Chalet Avatar answered Sep 18 '22 18:09

Kévin Chalet