September 2007

.NET Event Logging

(Nobody else will care about this. Move along. Nothing to see here now. Maybe I'll clean this up for public consumption later.)

After spending way too much time figuring out how to change the name of a custom event log my .NET-based service was writing messages to, I decided I need to save the snippet of code that finally worked.

For more info about the confusing world of .NET's EventLog class, see http://www.informit.com/guides/printerfriendly.aspx?g=dotnet&seqNum=238.

namespace BlahBlahBlah
{
    class Log
    {
        // Lots of stuff left out here.
        // ...

        private static EventLog eventLog = null;

        private static readonly string eventSource         = "My Service";
        private static readonly string eventLogName        = "My Log";
        private static readonly string eventLogMachineName = ".";  // local
        
        /// 
        /// Initializer for Log class
        /// 
        static Log()
        {
            // Register this event source if necessary
            try
            {
                bool needCreate = false;
                if (EventLog.SourceExists(eventSource))
                {
                    string logName = EventLog.LogNameFromSourceName(eventSource,
                                                                    eventLogMachineName);
                    if (logName != eventLogName)
                    {
                        EventLog.DeleteEventSource(eventSource);
                        needCreate = true;
                    }
                }
                else
                {
                    needCreate = true;
                }

                if (needCreate)
                {
                    EventLog.CreateEventSource(eventSource, eventLogName);
                }
            }
            catch
            {
                // Ignore failure
            }

            // Initialize our EventLog instance
            try
            {
                eventLog = new EventLog(eventLogName, eventLogMachineName, eventSource);

                // Ensure our event log has the "overwrite as needed" setting
                eventLog.ModifyOverflowPolicy(OverflowAction.OverwriteAsNeeded,
                                              eventLog.MinimumRetentionDays);
            }
            catch
            {
                // Ignore failure
            }
        }

        // Lots more stuff left out
        // ...
    }
}

New Eyeglasses


New Eyeglasses
Originally uploaded by kristopherjohnson

I've worn contact lenses since I was a teenager. I've never liked eyeglasses: they're too heavy, too fragile, too dusty, and just plain uncomfortable. In contrast, contacts are lightweight, they rarely get dirty, they provide peripheral vision, and you don't have to wear ugly clip-on sunglasses over them. I've never understood why anyone would prefer glasses, other than because their eyes simply can't handle them.

But, a persuasive woman suggested she'd like to see me in glasses more often, so I decided to give glasses another try. My fifteen-year-old pair had very large lenses, which are great for visibility but they are heavy and unfashionable. I wore them only in those rare times when my eyes were irritated by allergies or other problems. I decided to try some new frames, and after some searching, settled on this Ray-Ban #6127 Bronze frame.

I figure I'll wear them for the rest of the week to see if I can get used to them. I expect to be back in my contacts next week, except for time spent with the persuasive woman.

UPDATE: I hate wearing them, but the persuasive woman likes them, so, well...

Medication

Last week, I had my first complete physical exam in twenty years. I figured that, because I'm 40, I ought to get one. I was wondering what problems they might find.

EKG, heart sounds, lungs, reflexes, and everything were fine. However, my blood pressure was high. It was also high when I had my aviation exam, and both my parents have high blood pressure, so I finally had to accept the fact that I have a problem that probably can't be solved with rest, exercise, and a good diet. The doctor prescribed a daily dosage of blood pressure control medication.

Medication. In one sense, it's no big deal; lots of people are on medication. But, for the first time, I've been prescribed a daily dosage that I'll probably have to take for the rest of my life.

Does this make me officially middle-aged?

UPDATE: This means that if I want to fly again, I'll have to get cleared by the FAA medical staff again, which is a 4-to-6-week procedure. My medication is one that is approved by the FAA, but they review such things on a case-by-case basis.