Hi All,
I've implemented the IFileFactory that allows log4net to use an
externally defined factory object for file I/O operations. Are the CVS
diffs the best way to send this code to the group for inclusion in CVS?
I also have a small sample project that illustrates the use of the
attribute. If anyone is interested, I can zip it up and send or post
somewhere.
The way it works is much more elegant than suggested in my previous
post. Basically I added a new attribute called FileFactoryAttribute,
which allows an external DLL marked with this attribute supply the right
type info to log4net. For example, this could be placed on the user's
DLL:
[assembly:
log4net.Appender.FileIO.FileFactoryAttribute(FileFactoryType=typeof(Logg
ingTestApp.MyFileFactory))]
Assuming they have a class called MyFileFactory that derives from
IFileFactory, all file I/O can be done though the user's object.
public class MyFileFactory : IFileFactory
{
:
}
By using an attribute, it is easy to unplug the default factory without
needing to update config file entries. This is especially important for
upgrades to deployed applications which might have multiple pre-defined
config files, which allow the new mechanism to be supplied along with an
upgraded version of the application and a new log4net DLL, with no
config file changes required.
Just let me know the best way (assuming I'll email my CVS diffs) to get
these changes reviewed and included in the CVS.
-Doug