Pages

Monday, November 14, 2011

Log4NetDatabaseConfiguration Part2

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]

Step 5 : add New Console project for POC (LoggingExample) and add 2 config files . app.config and log4net.config
appconfig; put the configuration and modified it for the databse connection string

 
  
 

 
log4net.config:put the configuration

  
    
      
      
      
      
      
        
        
        
      
      
        
        
        
        
          
        
      
      
        
        
        
        
          
        
      
      
        
        
        
        
          
        
      
      
        
        
        
        
          
        
      
      
        
        
        
        
          
        
      
      
        
        
        
        
          
        
      
      
        
        
        
        
          
        
      
      
        
        
        
        
      


    
    
      
      
    
  


You are almost done for POC . Just two Steps Remening
Step: 6 . Create Table in Database
DROP TABLE [dbo].[ApplicationLog]
CREATE TABLE [dbo].[ApplicationLog] 
(
 [Id] int IDENTITY (1, 1) NOT NULL,
 [Date] datetime NOT NULL,
 [Thread] varchar(255) NULL,
 [Level] varchar(50) NOT NULL,
 [Logger] varchar(255) NOT NULL,
 [Host] varchar(50) NOT NULL,
 [Message] varchar(4000) NOT NULL,
 [Exception] varchar(2000) NULL,
 [severity] varchar(255) NULL,
 [useranme] varchar(255) NULL,
 [applicationName] varchar(255) NULL

)

Step:7 In Console application
using System;
using Database;

namespace LoggingExample
{
    class Program
    {
        static void Main(string[] args)
        {
            
            
                ILogger logger = new Logger();

                logger.EnterMethod("Main");
                logger.LogInfoMessage("LogInfo");
                logger.LogError("ErrorLog");
                logger.LeaveMethod("Main");
                       
        }
    }
}
You are done now !! if you like it please put a comment.
 Hope this will help you  :)

12 comments:

  1. It was so nice article and useful to Informatica learners. we also provide Dotnet Course online training our Cubtraining is leader in providing Software Training

    ReplyDelete


  2. very useful info, and please keep updating........

    ReplyDelete
  3. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information about the web design and web development.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.
    Hire .Net Developers India

    ReplyDelete
  4. At Coepd (Center of Excellence for Professional Development) we assume Object-Oriented Programming concepts and teaches C#.NET, ADO.NET which helps the attendees to build database-driven Web applications and Web Sites successfully. We also guide the attendees to develop web-based enterprise applications using ASP.NET and Visual Studio which comforts in developing the Web Services using .Net framework in Service-oriented Architecture.

    http://www.coepd.com/DotnetTraining.aspx

    ReplyDelete
  5. Hi, It's very best advantageous blogs.I read this subjects blog such a great blog and good sharing I'll be like this informative post.Thank you for selecting the time to provide us with your valuable knowledge.
    DOT NET Training Institutes in Ameerpet

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Worthful Devops tutorial. Appreciate a lot for taking up the pain to write such a quality content on Devops tutorial. Just now I watched this similar Devops tutorial and I think this will enhance the knowledge of other visitors for sure C#.NET Course In Hyderabad

    ReplyDelete