Loading the assembly for a custom log4net appender
As I described recently, I have built a
custom appender
that inherits from SmtpAppender but supports SSL sending
using .NET 2.0.
However, when I configure my
web application to use it, I get an error that:
log4net:ERROR
XmlHierarchyConfigurator: Could not create Appender
[EmailAppender] of type
[log4netExtensions.SmtpClientAsyncSmtpAppender]. Reported
error follows.
System.TypeLoadException: Could not
load type [log4netExtensions.SmtpClientAsyncSmtpAppender].
Tried assembly [log4net, Version=1.2.10.0,
Culture=neutral, PublicKeyToken=1b44e1d426115821] and all
loaded assemblies
It can't load the new
appender since that assembly isn't loaded. To specify
that an appender comes from a non-log4net assembly, you
add the assembly name after the appender. For
example,
<appender name="EmailAppender" type="log4netExtensions.SmtpClientAsyncSmtpAppender, log4netExtensions">
Note that you need to ensure that assembly is available, so you may need to add a reference to it in your project.