Saturday, 13 September 2008

Logging (not the tree kind)

Logging is a great tool when it has been implemented and things go wrong in production. ASP.NET applications can be a real bother when there is no logging of any sort.

I am a bit of a late starter when it comes to implementing logging within my applications and the only options I really had was writing either to the Event Log or writing to a database "Audit" table. Both options tend to involve writing a pile of code that I was never really all that happy about.

Then for a long while I kept hearing about a wondrous tool to solve all my logging woes... Log4Net

Log4Net just made logging so easy. I'd wrap Log4Net into my own custom class which would give me the basic methods to call appropriate Debug/Warning/Error/etc. methods and I would be away laughing.

Configuration was reasonably straight-forward. Log4Net gave me the flexibility to log "fatal" errors to the Event Log and/or email them to the appropriate person. All other levels of logging could be switched off and on at will and would log to a daily file.

All as sweet.

Then one day not too long ago I was watching a screen-cast from a certain fellow called Rob Conery. He just happened to brush upon the notion of logging within this particular installment of his MVC Storefront series but he wasn't using Log4Net!

Shock! Gasp!

*** NEWS FLASH ***

I seem to have killed Rob Conery's web site! Saturday 13th at 6:05PM NZ time... It may just be a coincidence. Or maybe it is just playing up for me. All I was doing was clicking on a tag in the tag cloud and it stopped working.

My bad.
*** NEWS FLASH ***

Anyhoo, back to the gasping...

He implemented not Log4Net but a relatively new kid on the blog... NLog

Dramatic riff...

I love it.

Just as simple to use as Log4Net and even easier to configure. More importantly easy to extend! The first thing I did was write my own custom layout renderer.

The documentation is quite straight-forward but I did have one stumbling block when I first tried to view all my wonderful new logging files NLog was now creating. Except it wasn't and it nearly put me off NLog because I couldn't see why.

Of course the problem boiled down to an assumption I'd made with the configuration that carried over from Log4Net.

When writing to a file I assumed it would be relative to the folder where my application was running and so I specified a relative path for the log file NLog was to write to.

Thanks to ProcMon from SysInternals I saw the error of my ways and then defined absolute paths for NLog. Of course, don't forget to make sure the account the worker process is running under has permissions to write to the location of your log files.

So like magic my application was now happily logging messages into the folder I designated for it.

And now I am happy and plan to use NLog in all my future applications.

Until something new takes my fancy of course...

NOTE: I am not sure how long Rob Conery's site was down for but was back up again 25 minutes later when I checked again.

Friday, 12 September 2008

Blog Template

I need a custom template!

I kinda like this pre-built template but I cannot really call it my own. For one thing the background pattern irritates me.

I'll need to put some thought into it this coming weekend...

NOTE: This post is testing the "future" posts feature. Hopefully this should be published automatically at 8:00am on the 12th of September 2008.

Not a very exciting note, but heck! This is my first blog and I'll get all excited over the little things if I wanna!

Monday, 8 September 2008

Points of Contact

I'm late! I'm late!

Oh dear, my membership was a little overdue. I thought I'd better pay it though I am a little unsure exactly why I am even a member of www.nzcs.org.nz

Granted there seems to be benefits to being a member but I have only been to one event since enrolling over four years ago. Has it really been a benefit to me?

Another group I seem to be a part of is Unlimited Potential. This one seems a little more hip than NZCS which seems to be a little more white collar.

Even though I've been a "member" for almost as long as NZCS, if memory serves, I have yet to make an UP event.

Now I'm really bad.

I one group I did turn up on a regular basis is the Wellington .NET User Group. It began with the Porirua .NET User Group but that seemed to fizzle out. I'm not even sure they still have a meeting. But I even gave up on the Wellington group even though I now work in town. I just don't seem to have the time any more.

Then other groups suddenly sprouted up all over the place. I tried to start going to the SQL Server group, but all it meant was I'd be eating more and more pizza.

Not really all that good for my waist-line.

Then those Geek Lunches started happening on a weekly basis. They were interesting and more importantly extremely handy as they were held across the road from were I worked.

But then my place of work moved and it was nolonger very convenient to walk halfway across town. I am basically a lazy bugger when left to my own devices.

I do regret letting the Geek Lunch thing flag as the people at those discussions are very clued into the technologies and methodologies I really need to get in to... I need more time in my day...

So what is my point?

There are so many great opportunities for getting out and meeting like-minded people who are driven and excited about the same things as I am. But I have to get myself off my A and get it into G and make the most of these opportunities. I am not getting any younger.

I have to stop making excuses and make the time to attend events and meetings again. I don't have to go to every single one of them. I'd never have time to spend with my fiance in that case.

But at least some of them... Starting tomorrow... Or next week... Once I'm over this cold...

Dammit!

Sunday, 7 September 2008

Dawn of a New Age

First!

Well I guess that was a given as this is my blog. If I wasn't first then something serious would be going on.

Fortunately all is well and this post marks the first post of my first blog... ever.

There isn't much for me to really blog about at this moment. All I'm doing is trying to set Blogger up for the first time. It is not going as swimmingly as I had hoped but I'm sure I'll get there in the end. Otherwise noone will ever get to see this post... Sad...

UPDATE
Seems all I had to do was to create my first post. This one in fact. Publishing zero posts just didn't move any files at all to my web host.

Now that I have successfully created my first post my next task I guess is to come up with the topic for my next post... Wish me luck!