1

We are using IdentityServer4 with ASP.NET Core. We want to write Identity Server's logs to an external file (i.g. log.txt). Can we do this via the log4net library?

Jeroen
  • 60,696
  • 40
  • 206
  • 339
Rakesh Kumar
  • 2,701
  • 9
  • 38
  • 66

2 Answers2

1

From the relevant IdentityServer docs:

IdentityServer uses the standard logging facilities provided by ASP.NET Core.

So in essence, your question nearly duplicates this question about hooking up log4net in ASP.NET Core. The top answer for that question also explains how to add a rolling file appender, which is what you'd need to get what you want.

That basically answers your question as currently written. If you need more specific advise, I recommend asking a question with your current attempted code / steps to reproduce your scenario.

Jeroen
  • 60,696
  • 40
  • 206
  • 339
  • thanks @Jeroen, after i checked the link("https://stackoverflow.com/questions/46169606/how-to-use-log4net-in-asp-net-core-2-0"), i have the same implementations as described, but i have got the error message on console windonw("log4net:ERROR ConfigureFromXml called with null 'element' parameter") – Rakesh Kumar Feb 26 '18 at 13:05
  • I suggest asking a fresh question then that includes an [mcve] so we can easily reproduce your scenario. Otherwise we'd be _guessing_ at the problem. – Jeroen Feb 26 '18 at 13:13
  • Link is broken. – kovac Feb 17 '19 at 14:49
0

.Net Core has pretty good logging support straight out of the box.

Have a read of this: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/?tabs=aspnetcore2x

mackie
  • 4,996
  • 1
  • 17
  • 17
  • 1
    thanks @mackie, now we are able to show logs on console window, so how can we write those into a text file? – Rakesh Kumar Feb 26 '18 at 11:58
  • Looks like there isn't a standard one but plenty of articles out there on how you roll your own. – mackie Feb 26 '18 at 12:01
  • and my original question was related to write Identity server's logs into a text file, can we do this in the same way? – Rakesh Kumar Feb 26 '18 at 12:04