tags:

views:

39

answers:

2

Hello Evryone

I would really apreciate if some one kindly clarify my confusion. I'm doing my internship in a company that develops and monitors prepaid reload systems in .NET framework and we are using C# currently, and i am required to research log4net and help them elevate their logging framework from simple logging to advanced logging with several appenders and layouts. So far i been told to investigate log4net. I read tutorials and basicaly i done it with console app and also simple web app, but the problem is the logging happens when i run the application and i dont want that since the applications are already running on a server. some one kindly tell me a way to acomplish the logging without needing to debug the applications and making it log on entry point. I'm pretty much confused coz am new to the whole thing. Thanks in advance

A: 

If they want you to use log4net, they'd be happy to restart an updated program on the server. After all, you'll want to actually add logging to the program you want logged.

With that, if you're using a log4net configuration file, your program will listen to that file and you can change it whenever you want without restarting or recompiling the application. This goes into effect immediately, so you get great flexibility.

If you want to monitor things centrally, you might consider logging everything to a database. I use Log4View (commercial program) with their TCP remoting, which is nice.

Michael Hedgpeth
thanks micheal for the immediate reply. i will direct my research to the configuration of log4net in xml format.One more question. If i configure log4net using xml file, do i need to put it in the root directory of each application? or i can just save in my directory and reference it in my assembly directing it to the location(such as "C://logfile.config") so that i can create the configuration file once and not copy to all apps. Is it posible?
Precious
If you put it in the same directory as the executable, you can go to the AssemblyInfo.cs and add a line of code to watch for it. Otherwise, you'll have to wire up the configuration manually. I hope that helps!
Michael Hedgpeth
A: 

What you need to build is a receiver. Log4net has a plugin architecture which supports what you are describing. More documentation is here:

http://logging.apache.org/log4net/release/manual/plugins.html

Excerpt:
RemoteLoggingServerPlugin

Creates a remote logging sink that can receive logging events from a RemotingAppender. Creates a remoting logging sink. A single parameter must be passed to the constructor that specifies the sink URI. This is a name used to identify the logging sink object published via remoting and must be agreed with the client before communication can take place.

Example usage:

LogManager.GetRepository().PluginMap.Add
  (new RemoteLoggingServerPlugin("LoggingSink"));
code4life
thanks code4lifei will look into this one. the documentation contains minimum info for a beginner but i will google and try and find detailed articles.
Precious