How to configure log4net for applications we are developing and running on our servers?
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 开发者_JS百科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
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"));
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.
精彩评论