Tuesday, September 23, 2008

Logging to the database with Enterprise Library


I have since started my own implementation which is describered in the following articles:


So I've been using the Enterprise Library's logging block since v1; however, I've always logged to mostly unstructured or semi-structured locations such as email, files or the event log. I've had a lot of success using the block for logging exception messages or basic application events.

In all the apps I've ever written I've always had a need for a more robust strongly structured data store to facilitate reporting, and I've always resorted to rolling my own. Over the years the implementations have varried from very narrowly focused systems that support a single subsystem to more generic mechanism that support a various paradigm. For example logging of the messages within an SOA environment.

  • Incoming Message
  • Outgoing message to the next service
  • Reponse from that service
  • Response to the original request.

When ever its time to implement these systems, our team would always debate if we could leverage the Enterprise Library logging block; however, we've found that it was always easier to just roll our own quick dirty logger.

Today I had to ask this question again, only this time I am a team of one so I only had myself to argue with. I want to store an audit trail when a user logs into my web application, and collect all the fun stats such as his browser. (I know I could look at the iis logs but that won't let me profile which browsers have access to certain features, without having to figure out which urls if any compose a specific feature...this can be a whole other post so I will leave it at this).

The enterprise library does support a datbase trace listener out of the bat; however, it is seriously flawed. The listener can only log to a very specifc table structure. There is no way to say, I want to add this piece of information such as the IP Address of the client to the table as a seperate field.

The table does a text field called FormattedMessage which will use an Formatter that is asociated with the listener to generate a message. So while it is possible to get my IP Address in there, it forces to fall back onto to a non-relational model such as XML. While I love this flexibility, I've seen many DBA pulling their hair out at 3:00 am when they need to pull and aggregate data from a XML blob. Since this is a text field and not the Xml Data Type, I can't really enforce a schema.

So what is a poor developer to do? Well I don't have a solution implemented yet...But I plan on creating my own database trace listener that will let you specify the parameters and how to pull the values from the LogEntry object dynamically.

If I make any progress I'll add a new post. If anyone is aware of any solutions out there let me know.



Saturday, September 6, 2008

Setting up a printer on Windows Home Server

I recently won an HP Home Server (I actually got it about a month ago and decided to break it out of the box today). Its amazing how much life has changed for me in 10 years with a wife and three kids. 10 years ago that server would have been unpacked and up and running within an hour of getting it.

Anyways so far I am fairly happy with how easy it has been to setup the media server. I've just finished adding my Lexmark 5495 to the server, it took me longer to find the right drivers then it did to actually install them.

My only issue with the process is that you have to use remote desktop and login to the server. The help documentation for Home Server actually advises that you do not do this. Sharing resources like a printer seems like such a common task that it would have been nice for them to find a way to integrate into the Home Server Console.

To install a printer you can simply hook the printer into the USB or Parralel port, and then one of two things will happen. Either the server will detect the printer and install the printer or you will have to do this manually. You can check if the printer was installed by going to the shared folders and you should see the printer, if you do not then you will need to do it manually.

To do this open up remote desktop and connect to the server. Then you will install the drivers just as you would on any other computer.

Once the printer is installed you can connect to it by going to \\YourServerName\Printers You will also see the printer at \\YourServerName\NameOfYourPrinter. When you right click on the printer you can select connect and it should install the drivers for you.