473,513 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1752

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

Similar topics

3
732
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
3274
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
1707
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
466
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
5134
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
8093
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
1064
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
2089
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
20013
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
1469
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
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7537
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7525
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5086
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.