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?
Asked
Active
Viewed 217 times
1

Kirill Mehtiev
- 15
- 1
- 3
-
Serilog has a file sink and rolling file sink, and works with .NET Core. See http://stackoverflow.com/a/35052615/409259 – Jeff Ogata Jan 29 '16 at 12:00
-
Thanks good example! – Kirill Mehtiev Jan 29 '16 at 18:03
1 Answers
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