1

Is it possible to use built-in logging to file in dnx? I tried to use System.Diagnostics.TextWriterTraceListener but is not available in .Net Core. Any suggestions?

1 Answers1

1

By itself, ASP.NET Core’s logging system does not come with a file-based logging provider.

It would be pretty simple to roll your own though; just look at the Debug logger as an example to see what you need to do.

Of course, you could also use another logging framework that already supports this. For example NLog – a .NET Core compatible version is in alpha. Another example would be Serilog which also has .NET Core versions in beta (versions 2.x)

If you run your app through IIS, you can also use IIS’ file logging to redirect the stdout logging into files. This can be configured in the web.config.

poke
  • 369,085
  • 72
  • 557
  • 602
  • Have you found any working examples NLog with dnxcore50? All examples I found run on dnx451 like this [link](https://github.com/aspnet/Logging/tree/dev/samples/SampleApp) – Kirill Mehtiev Jan 29 '16 at 18:28
  • I’d guess that you just have to change the `project.json` to reference the alpha version of NLog. – poke Jan 29 '16 at 18:31