473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

What are the steps in Log4Net?

Add a reference to log4net.dll

1: In the APP.CONFIG write the following:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net"
type="System.Configuration.IgnoreSectionHandler" />
</configSections>
<!-- This section contains the log4net configuration settings -->
<log4net>
<!-- Define some output appenders -->
<appender name="RollingLogFileAppender"
type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs/RReaderRoll.txt" />
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="10" />
<param name="MaximumFileSize" value="15000" />
<param name="RollingStyle" value="Size" />
<param name="StaticLogFileName" value="true" />
<param name="ImmediateFlush" value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d %-5p %c{1} [%x] -
%m%n" />
</layout>
</appender>
<appender name="LogFileAppender"
type="log4net.Appender.FileAppender">
<param name="File" value="logs/RReaderAll.txt" />
<!-- Example using environment variables in params -->
<!-- <param name="File" value="${TMP}\\log-file.txt" /> -->
<param name="AppendToFile" value="true" />
<param name="ImmediateFlush" value="true" />
<!-- An alternate output encoding can be specified -->
<!-- <param name="Encoding" value="unicodeFFFE" /> -->
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d %-5p %c{1} [%x]
&lt;%X{auth}&gt; - %m%n" />
</layout>
<!-- Alternate layout using XML
<layout type="log4net.Layout.XMLLayout" />
-->
</appender>
<appender name="ConsoleAppender"
type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d %-5p %c{1} [%x]
&lt;%X{auth}&gt; - %m%n" />
</layout>
</appender>
<!-- Setup the root category, add the appenders and set the default
level -->
<root>
<level value="INFO" />
<appender-ref ref="LogFileAppender" />
<appender-ref ref="ConsoleAppender" />
</root>
<!-- Specify the level for some specific categories -->
<logger name="Riag.CCard.ResponseReader.ReaderMain">
<level value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
</logger>
</log4net>
</configuration>
2. In the class

class ReaderMain
{
// Create a logger for use in this class using Log4Net.
private static readonly log4net.ILog log =

log4net.LogManager.GetLogger(System.Reflection.Met hodBase.GetCurrentMethod().DeclaringType);

....
....
3. In the code write

log.Error("Unable to process xml file.");
log.Info("Unable to process xml file.");
log.Fatal("Unable to process xml file.");

Jul 21 '05 #1
0 1695

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Joneleth | last post by:
Hi, anyone can help with log4net? i'm not sure i understand log4net object model properly... i'm trying to configure log4net programmatically, in order to assign different custom appenders to...
0
by: Ravindra.H | last post by:
Hi, We are trying to evaluate use log4net v1.1.1. When we try to execute the sample application "TestApp" that is provided with the actual source code, we get the following errors: ...
1
by: Bob | last post by:
The raging question that is going on currently is about log4net vs. EIF. I feel that EIF is complex and incomplete at this point. By incomplete, I mean MS is still fiddling with it. log4net is...
1
by: Ram | last post by:
Hey, I'm using the Log4Net opensource object to write to my logs. I'v written a wrapper ClassLibrary project for the Log4Net and all my projects reference only to it. I'v got a web application...
0
by: anonieko | last post by:
Add a reference to log4net.dll 1: In the APP.CONFIG write the following: <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="log4net"...
4
by: Dhans | last post by:
Hi there, I am using log4net in my (.net v1.1) application to log the messages. I tried to clear the logfile while application is running. since log4net has the file handle it did not allow me to...
2
by: Vikram | last post by:
I am using log4net in a vb.net console application. But its not working. I have added congif setting in app.config file also No error is generated but app. does not write to log file. ...
2
by: harish.c27 | last post by:
HI All, Here is my problem: log4net works fine with my Client (Windows Application .Net 1.1) but does not log any thing when i use it in my server (Com+ DLLs). Does any one know why or how to...
0
by: chatuk | last post by:
Hello, I have setup log4net with rolling file appender as per the config below: <appender name="RollingFile" type="log4net.Appender.RollingFileAppender"> <file...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.