How to add logging in razor views? I would like to add debug statements using logging tool such as log4net?
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.
I agree with the other replies but this would be for temparary debugging such finding out count or similar scenario.
After fiddling around a little, following syntax worked.
@ViewBag.Log.Debug("Products count = " + Model.Products.ToList().Count);Hope this will help someone.