Question
Accenture
DE
Last activity: 14 Mar 2018 12:34 EDT
How to Change Log4Net Rolling file appender to smtp appender or ADODB appender
Hi All,
Currently log4net publisher logs the data in a file according to the configuration done in Runtimeconfig.xml > log4net publisher > innerXML.
I want the log4net to publish into different appenders such as SMTP or ADO.NET and other things. I tried changing the inerXML to appropriate appenders ( as given in the url :https://logging.apache.org/log4net/release/config-examples.html by appropriate encoding) and getting the below error. Does any one have idea how to use it or open span does not support it ?
OpenSpan.Diagnostic Internal Exception
Exception Report
1) Exception Information
*********************************************
Exception Type: System.InvalidCastException
Message: "Unable to cast object of type 'log4net.Appender.SmtpAppender' to type 'log4net.Appender.FileAppender'."
Data: IDictionary (System.Collections.ListDictionaryInternal) with 0 items
TargetSite: Boolean Initialize(System.String, System.Collections.Specialized.NameValueCollection, Boolean)
HelpLink: NULL
Source: "OpenSpan"
HResult: -2147467262
StackTrace Information
*********************************************
at OpenSpan.Diagnostics.Publishers.Log4NetPublisher.Initialize(String identity, NameValueCollection settings, Boolean validateInternalState)
at OpenSpan.Diagnostics.Diagnostic.Initialize()
*********************************************
Hi All,
Currently log4net publisher logs the data in a file according to the configuration done in Runtimeconfig.xml > log4net publisher > innerXML.
I want the log4net to publish into different appenders such as SMTP or ADO.NET and other things. I tried changing the inerXML to appropriate appenders ( as given in the url :https://logging.apache.org/log4net/release/config-examples.html by appropriate encoding) and getting the below error. Does any one have idea how to use it or open span does not support it ?
OpenSpan.Diagnostic Internal Exception
Exception Report
1) Exception Information
*********************************************
Exception Type: System.InvalidCastException
Message: "Unable to cast object of type 'log4net.Appender.SmtpAppender' to type 'log4net.Appender.FileAppender'."
Data: IDictionary (System.Collections.ListDictionaryInternal) with 0 items
TargetSite: Boolean Initialize(System.String, System.Collections.Specialized.NameValueCollection, Boolean)
HelpLink: NULL
Source: "OpenSpan"
HResult: -2147467262
StackTrace Information
*********************************************
at OpenSpan.Diagnostics.Publishers.Log4NetPublisher.Initialize(String identity, NameValueCollection settings, Boolean validateInternalState)
at OpenSpan.Diagnostics.Diagnostic.Initialize()
*********************************************
Note : i am able to achieve it using script method and the appender of my choice, but i want to achieve using the built-in log4net publisher and avoid C# scripting.