C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






using log4net.dll in our applications


Posted Date: 06 Jun 2008    Resource Type: Code Snippets    Category: ASP.NET WebForms
Author: komaladeviMember Level: Gold    
Rating: Points: 10



Log4net.dll will be useful for logging the debug logs .For this All you have to do:

* Add reference to log4net.dll
* Add imports for log4net and log4net.Config namespaces (either in project level or in each Class file in your app)
* Call once of the log4net’s BasicConfigurator class ‘Configure’ method in your main Class.
* Create logger instance in each of your Classes


get the lattest version of log4net.dll



and add the following code in iin your web.config oor app.config



<configuration>


<configSections>

<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>

</configSections>




<log4net>

<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">

<file value="c:\temp\web.log" />

<appendToFile value="true" />

<maximumFileSize value="1024KB" />

<maxSizeRollBackups value="10" />

<layout type="log4net.Layout.PatternLayout">

<conversionPattern value="%date %level %logger - %message%newline" />

</layout>

</appender>



<root>

<level value="ALL" />

<appender-ref ref="RollingFile" />

</root>

</log4net>



</configuration>





now import the dll in to our application and
then add add as below

Imports log4net
Public Class Form1
Dim log As log4net.ILog
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
log4net.Config.XmlConfigurator.Configure()

log = log4net.LogManager.GetLogger("MyApp"")

End Sub



and log it in any of the application like as below


Private Sub cmdDebug_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDebug.Click
log.Error("'Debug'----komala1")
End Sub





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Add New Row to GridView and save it to Database
Previous Resource: How Dynamically Insert Javascript into Asp.net
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use