0

I am using log4net to log my microservices application. I have created a nuget package to house some reusable code.

This is my logging declaration in all my classes.

protected static readonly ILog Log = LogManager
     .GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

Obviously, when I use this declaration inside my nuget package, it creates a log4net logger of my nuget package type. I lose context of which microservice I am in.

Can I get a logger that reflects the calling method? Or ideally, as well as the nuget package class?

1 Answer 1

1

I may be mis-understanding but couldn't you just use Environment.Stacktrace and log the last method outside of your nuget package's namespace?

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

1 Comment

Possibly, I'd really like to be able to get both, the nuget class and the calling method.

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.