Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys, I need the log info for each and every session created in the web application in asp.net.
the log file must be rollback by size 5
I am using the following code. For each time the log file created i need to specify the logger configuration in the log file, after that I need to create separate log file for each and every session. If a user logins means a separate log has to created untill his session expires.

Is there any solutions available for that.

<script  runat="server">

    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();
    }
       
</script>



Thanks in advance.
Posted
Updated 23-Apr-13 4:43am
v2
Comments
StianSandberg 23-Apr-13 9:45am    
What have you tried?
Richard C Bishop 23-Apr-13 9:49am    
Read your thread and tell me if you think something is missing.
ZurdoDev 23-Apr-13 10:36am    
What code are you using? Just use the Session_Start event in global.asax and do what you need. Where are you stuck?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900