When writing to an event log, I can create an instance of EventLog, hold onto it as a member variable and call WriteEntry(string message) on it every time I want to log a message.
Alternatively, I can just call the static version: EventLog.WriteEntry(string source, string message).
Should I prefer one alternative over the other?
In my current situation I intend to have a custom log with one or two sources.
If you are writing test driven or unit testing your code, the use of a static class is not recommended.
I would wrap EventLog in a class that implements a generic ILog interface. You can inject this class or instantiate it within each class that uses it. This should give you the best flexibility going forward should you need to replace EventLog with some other logging method.
Example Interface:
public interface ILog
{
void Info(string format, params object[] args);
void Warn(string format, params object[] args);
void Error(Exception exception);
}
You can extend or alter this to create a contract that makes sense to you.