473,569 Members | 2,555 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use log4net for a windows forms application using COM classes

Hi all,
I would like to implement log4net for logging my application. First
let me describe in short about the application. I have a solution with
two exe file outputs and several dll assemblies. And my application has
a different AppDomain as it is a customization of another COM based
application written in VB.NET.

I have tried with App.Config files in my startup exe applications. It
works fine only till the parent application is loaded after that even
though the customized assemblies are used. My logging is not happening.
I am using the following set of code in every class.

1) log4net.Config. DOMConfigurator .Configure(); in every class'
constructor
2) Private Shared ReadOnly log as ILog =
LogManager.GetL ogger(GetTypeof (FastLogger));

My installation folder has the following files apart from other
assemblies:

1) MyApp.Exe
2) MyApp.Exe.Confi g
3) But it starts another application ForeignApp.exe in some other
folder.

Can anyone please help me in this regard.

Thanks in anticipation,
Chidam

Dec 7 '06 #1
1 5161
You have a more complicated setup than I have dealt with in .net, but
in java it was easy enough. I sure hope it's that way here.

I have a "log4net.config " file in my app directory
I do *not* initialize log4net anywhere
In my assemblyinfo is this line which causes log4net to reload itself
if the config changes:
<Assembly: log4net.Config. XmlConfigurator (ConfigFile:="l og4net.config",
ConfigFileExten sion:="config", Watch:=True)>

At the top of each class is this generic code :
Private Shared ReadOnly log As ILog =
LogManager.GetL ogger(System.Re flection.Method Base.GetCurrent Method().Declar ingType)

This gets a logger based on the class being instantiated. In other
versions with the plain text config file you could always just
reference your class/namespace like this :
"log4j.logger.c om.myapp.data=d ataquerylog,ema ilerrorlog" and it would
use those loggers for all classes in that namespace that loaded a
logger that was not explicitly named (ie, FastLogger). I assume there
is a way to do this in the xml config file (or maybe it supports a text
config too?) and maybe that is what you are looking for.

Hope this helps. If a second exe is run in the same working directory
I think it would load up the same log4net.config (xml format) when run.
HTH, and sorry I can't be much more help than that.

// Andrew

ch***********@g mail.com wrote:
Hi all,
I would like to implement log4net for logging my application. First
let me describe in short about the application. I have a solution with
two exe file outputs and several dll assemblies. And my application has
a different AppDomain as it is a customization of another COM based
application written in VB.NET.

I have tried with App.Config files in my startup exe applications. It
works fine only till the parent application is loaded after that even
though the customized assemblies are used. My logging is not happening.
I am using the following set of code in every class.

1) log4net.Config. DOMConfigurator .Configure(); in every class'
constructor
2) Private Shared ReadOnly log as ILog =
LogManager.GetL ogger(GetTypeof (FastLogger));

My installation folder has the following files apart from other
assemblies:

1) MyApp.Exe
2) MyApp.Exe.Confi g
3) But it starts another application ForeignApp.exe in some other
folder.

Can anyone please help me in this regard.

Thanks in anticipation,
Chidam
Dec 7 '06 #2

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

Similar topics

6
5737
by: Hamed | last post by:
Hello I have employed as a developer in a software company that its team uses FoxPro / VB 6.0 / VC++ 6.0 as the developing tools and newly is going to migrate to VS.NET. There is a project modified that is to upgrade a big, more than 100,000 lines DOS based program developed by FoxPro 2.x to .NET platform. The design is as previous and...
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 given in the log4net config file. Please help
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 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...
4
2972
by: waltborders | last post by:
Hi, Because the blind are unable to use a mouse, keyboard navigation is key. A major difficulty is that not all windows forms controls are keyboard 'tab-able' or 'arrow-able' or have "tab order". The application is built and the next step is to create the custom JAWS (Freedom Scientific)screen reader script to read the application. The...
4
2198
by: Gawel | last post by:
hajo, can someone send me an example how to use above pattern in asp.net applicaiton? I can not figure out how to do it. I get no exceptions, simply no logging occures. Thanks for any info Gawel
4
10560
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 clear/delete the file. I need to clear the content of the log file specified in the log4net configuration file, when it is needed in the...
2
5144
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. app.config file: <?xml version="1.0" encoding="utf-8" ?>
6
8098
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 create more loggers (subloggers). This is nice since I can use just one configuration file to control the behaviour of all the loggers within my app....
2
20018
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 supplied with the source are anything but helpful. Thanks for any input. -fd
0
7701
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7615
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.