0

I have a .Net Web Application which I am successfully logging to file using Serilog and the File Sink. The main application is setting up the logger in the global.asax application start.

The web application assesses web services (also written by me) and I want to log from within the web-service (asmx) but I can't get it to write anything. I have tried multiple ways including setting up the LoggerConfiguration directly before calling the Log functions but with no luck. I have also enabled SelfLog and nothing is output.

Any assistance would be greatly appreciated - I've been googling this all day.

1 Answer 1

1

In order to get Serilog working in an ASMX web-service I had to declare a private static logger at the top of the service:

private static Serilog.Core.Logger myLog = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.File(HttpContext.Current.Server.MapPath("~/logs/QuoteEngine.txt"), rollingInterval: RollingInterval.Day).CreateLogger();

I then call:

myLog.Error("Your string") or myLog.Debug("Your string") etc

I hope this helps someone having same issues finding the answer.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.