I agree with the other answers, but that would be to debug such search counts or similar scenarios.
After a little twist, the syntax worked.
@{ ViewBag.Log = log4net.LogManager.GetLogger("Products.cshtml");}
@ViewBag.Log.Debug("Products count = " + Model.Products.ToList().Count);
Hope this helps someone.
source
share