473,322 Members | 1,510 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,322 software developers and data experts.

Log4net trouble

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 some custom loggers (run-time) and (i
think) i've been able to add new custom loggers to the root logger of
the repository. i've also added one appender for each custom logger.

this is the code snippet i wrote:
---------------------------------------------------------
log4net.Repository.Hierarchy.Hierarchy hier =
(log4net.Repository.Hierarchy.Hierarchy)log4net.Lo gManager.GetRepository();

//customizing server logger(s)
log4net.Repository.Hierarchy.Logger ServerLogger = null;
ServerLogger = hier.LoggerFactory.CreateLogger("ServerLogger");
ServerLogger.Level = log4net.Core.Level.Info;
ServerLogger.AddAppender(CreateTextBoxAppender()); //add textbox
appender

//customizing client logger(s)
log4net.Repository.Hierarchy.Logger ClientLogger = null;
ClientLogger = hier.LoggerFactory.CreateLogger("ClientLogger");
ClientLogger.Level = log4net.Core.Level.Info;
ClientLogger.AddAppender(CreateTextWriterAppender( )); //add textwriter
appender

hier.Configured = true;
LogManager.GetRepository().Configured = true;
XmlConfigurator.ConfigureAndWatch(LogManager.GetRe pository(), new
FileInfo(filename)); //filename = App.config file path
---------------------------------------------------------
now, when i try to retrieve the custom logger i have just created using
LogManager.GetRepository().GetLogger("ServerLogger ") or
hier.GetLogger("ServerLogger")
log4net create a new Logger instance named "ServerLogger" as well,
without any appenders.
how if i need to use my custom logger inside any class of my
application?

thanks in advice
J.

Nov 22 '05 #1
0 1736

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

Similar topics

3
by: SK | last post by:
Hi, I am using log4net in my c# application.Want to know how to customize the log output format. I know that it can be done using LayoutSkeleton class,but dont know what other parameters to be...
1
by: Abelardo Vacca | last post by:
Hello, Could anyone point out advantages and disadvantages of Apache's Log4net and Microsoft's Exception Management Application Block? I am leaning towards log4net, but I've read it can give...
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"...
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...
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. ...
6
by: Mr Flibble | last post by:
Hi all, I've decided to use log4net for my logging/tracing. In the example on the site it shows using main() to setup the root logger and then using the LogManager within your classes to...
0
by: Marc Scheuner | last post by:
Folks, I'd really like to use log4net for our error logging, but I'm having two problems: 1) For certain cases, I'd like to log error and messages to text files. I tried both the regular...
2
by: Marc Scheuner | last post by:
Folks, I'd really like to use log4net for our error logging, but I'm having two problems: 1) For certain cases, I'd like to log error and messages to text files. I tried both the regular...
2
by: forest demon | last post by:
I need to be able to create an appender to direct output to a MessageBox. The API does not have a MessageBox appender like nLog does. What would be the easiest way to do this. The examples...
0
by: rosshinkley | last post by:
Greetings. I know that log4net supports filtering based on properties (log4net.Filter.PropertyFilter). Trouble is, I'm having trouble spotting what valid property names are. Are they intrinsic...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.