There is no template element for the request URL. You can add the request URL to the advanced properties yourself so that the information is logged:
string requestUrl = System.Web.HttpContext.Current.Request.Url.AbsoluteUri; Dictionary<string, object> dictionary = new Dictionary<string, object>(); dictionary.Add("RequestUrl", requestUrl); Logger.Write("My message", dictionary);
Since the formatter logs all dictionary words / meanings, your RequestUrl will be displayed in the log.
An alternative approach would be to create your own IExtraInformationProvider to populate the specific web information you are interested in. This is really the same except using the Enterprise Library interface.
public class WebContextInformationProvider : IExtraInformationProvider { public void PopulateDictionary(IDictionary<string, object> dict) { dict["RequestUrl"] = System.Web.HttpContext.Current.Request.Url.AbsoluteUri; } } Dictionary<string, object> dictionary = new Dictionary<string, object>(); WebContextInformationProvider webContext = new WebContextInformationProvider(); webContext.PopulateDictionary(dictionary); Logger.Write("My message", dictionary);
source share