|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
Figure 1. Computer Management console screen-shotIntroductionA quick-and-easy distributed application logger (AppLogger) was introduced in Part 1 of this article. TCP Remoting was used as the underlying protocol that makes AppLogger "distributed". The use of BusinessFacade, BusinessRules, DataAccess and SystemFrameworks layers was also presented as a way to structure your application. It was also mentioned that logging should be a short-and-fast action, i.e. the caller should never be in a blocking state. "Asynchronization" was implemented server-side in AppLogger's BusinessRule layer. In this article, we will "refactor" AppLogger to make it even more "asynchronous". In fact, we want to make the client-side calls (via To run the demo, just unzip the demo files, and do the following:
BackgroundIn an ideal world, application error logging should be an exception and not the norm. If there are so many errors and exceptions to log, your applications are already functioning in degraded mode. However, this world is less than ideal (as we all know it), and more often than not we even need to log debug messages just to keep us happy that things are running fine. So in order not to "degrade" our AppLogger, we want to make the APIs provided by AppLoggerHelper asynchronous. In essence, users of AppLoggerHelper will effectively "enqueue" their log messages and AppLogger will "dequeue" and forward them to the concrete IAppLogger. As usual, we will touch base with a few design patterns along the way. Features
The following has been added to the projects in AppLogger solution:
The AppLogger.exe ConfigurationAppLogger.exe's App.Config has a new key call "AppLogger.MSMQ". Note that "bordeaux" is my machine name, change it to your machine name (not necessarily "chablis", just joking...). <appSettings>
<!--
AppLogger.Type allows changing the type
of logger during runtime. Eg. ConsoleLogger,
FileLogger, EventLogger, DbLogger, DebugLogger
-->
<add key="AppLogger.Type"
value="AppLogger.BusinessRules.ConsoleLogger" >
...
<!--
AppLogger.MSMQ is for MsmqLogger only.
Private queue "applogger" must exists in local machine.
Client side must have the following in <appSettings>
<add key="AppLogger.Home.Location"
value="msmq:FormatName:DIRECT=OS:<hostname>\private$\applogger" />
Server side, which is this App.config,
must have the following in <appSettings>
<add key="AppLogger.MSMQ"
value="FormatName:DIRECT=OS:<hostname>\private$\applogger" />
-->
<add key="AppLogger.MSMQ"
value="FormatName:DIRECT=OS:bordeaux\private$\applogger" />
</appSettings>
Client ConfigurationIn AppLoggerTest's App.Config, only the value of the key "AppLogger.Home.Location" needs to be changed to using "msmq:" protocol. <appSettings>
<!--
AppLogger.Home.Location refers to the URL of AppLogger's IHome
<add key="AppLogger.Home.Location"
value="tcp://localhost:20911/AppLogger.IHome.rem" />
OR via MSMQ
<add key="AppLogger.Home.Location"
value="msmq:FormatName:DIRECT=OS:<hostname>\private$\applogger" />
-->
<add key="AppLogger.Home.Location"
value="msmq:FormatName:DIRECT=OS:bordeaux\private$\applogger" />
...
</appSettings>
Using the code
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 15 Jul 2004 Editor: Nishant Sivakumar |
Copyright 2004 by sebma Everything else Copyright © CodeProject, 1999-2008 Web19 | Advertise on the Code Project |