What is the best logging pattern for asp.net mvc 2 using log4net? When should I initialize logger how should I access logger instance?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
We follow the same pattern that we use for all apps:
Create a logger inside each class, setting the class type as the logger name and log everything that need to be logged inside the class to the local logger. Like this (for example… there are other ways to declare the logger):
If you’re so inclined you could try to weave a logging aspects throught your class, but sometimes you need finer grained control, which is why we go through the process of putting them in by hand.