我需要在登录后为每个用户创建一个新的日志文件。我还需要在日志文件中为每个新会话指定记录器配置。
有没有可用的解决方案。 Global.asax中
void Application_Start(object sender, EventArgs e) { log4net.Config.XmlConfigurator.Configure(); log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); logger.Info("Logger Process Started"); logger.Info("*********************************************************"); logger.Info("Name of The Project :" + "Reporting and Task Navigation"); logger.Debug("Release date :" + DateTime.Today); logger.Debug("Release Version :" + ConfigurationManager.AppSettings.Get("releaseVersion")); logger.Info("Release date : " + DateTime.Today); logger.Info("Release Version : " + ConfigurationManager.AppSettings.Get("releaseVersion")); logger.Debug("Environment OS :" + Environment.OSVersion.ToString()); logger.Debug("Frame work :" + Environment.Version); logger.Info("LogFileName - " + ConfigurationManager.AppSettings.Get("fileValue")); logger.Info("MaxSizeRollBackups -" + ConfigurationManager.AppSettings.Get("maxSizeRollBackups")); logger.Info("MaximumFileSize - " + ConfigurationManager.AppSettings.Get("maximumFileSize")); logger.Info("DatePattern - " + ConfigurationManager.AppSettings.Get("datePattern")); logger.Info("ConversionPattern -" + ConfigurationManager.AppSettings.Get("conversionPattern")); logger.Info("Logger Details assigned Successfully"); logger.Info("End of the Logger Initialising Process"); logger.Info("*********************************************************"); logger.Info(""); } void Application_End(object sender, EventArgs e) { // Code that runs on application shutdown } void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs } void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started } void Session_End(object sender, EventArgs e) { //log4net.LogManager.ResetConfiguration(); }
编辑:我尝试在登录成功后放置日志文件创建代码但我无法记录登录失败数据。
在登录后创建打印日志模板的任何想法也记录有关登录过程成功和失败方案的数据。
提前致谢
我找到了问题的解决方案而不是在global.asax中加载记录器,我使用回发加载到应用程序起始页面(登录页面),因此每当创建新的sessin时它都会创建一个新文件。