hi, My objective is to log in oracle 10g using log4net through stored procedure. I have made configuration in log4net configuration xml file to use ado.net appender and use stored procedure for Logging in db. I want to log exceptions in db with parameters like error code, error message, etc. Please guide me how to pass this Exception object using C# CODE for writing in db. I have made proper configurations in xml for stored procedures.
Thanks.
Code is as follows:
string logFilePath = AppDomain.CurrentDomain.BaseDirectory + "log4netconfig.xml";
FileInfo finfo = new FileInfo(logFilePath);
log4net.Config.XmlConfigurator.ConfigureAndWatch(finfo);
ILog logger = LogManager.GetLogger("Exception.Logging");
log4net.ThreadContext.Properties["INNER_EXCEPTION"] = exception.InnerException.ToString();
log4net.ThreadContext.Properties["INNER_EXCEPTION"] = string.Empty;
log4net.ThreadContext.Properties["STACK_TRACE"] = exception.StackTrace.ToString();
log4net.ThreadContext.Properties["STACK_TRACE"] = string.Empty;
log4net.ThreadContext.Properties["MESSAGE"] = ((H2hException)exception).Message;
log4net.ThreadContext.Properties["CODE"] = "err-1010";
log4net.ThreadContext.Properties["MODULE"] = "NED.Development";
log4net.ThreadContext.Properties["COMPONENT"] = "Component";
log4net.ThreadContext.Properties["ADDITIONAL_MESSAGE"] = "msg";
logger.Debug("");
<parameter>
<parameterName value="@p_Error_Code" />
<dbType value="VARCHAR2" />
<size value="16" />
<!--<layout type="log4net.Layout.PatternLayout" value="%level" />-->
<conversionPattern value="%property{log4net:CODE}"/>
</parameter>
<parameter>
<parameterName value="@p_Error_Message" />
<dbType value="VARCHAR2" />
<size value="255" />
<!--<layout type="log4net.Layout.PatternLayout" value="%logger" />-->
<conversionPattern value="%property{log4net:MESSAGE}"/>
</parameter>
<parameter>
<parameterName value="@p_Inner_Exception" />
<dbType value="VARCHAR2" />
<size value="4000" />
<!--<layout type="log4net.Layout.PatternLayout" value="%thread" />-->
<conversionPattern value="%property{log4net:INNER_EXCEPTION}"/>
</parameter>
<parameter>
<parameterName value="@p_Module" />
<dbType value="VARCHAR2" />
<size value="225" />
<!--<layout type="log4net.Layout.PatternLayout" value="%message" />-->
<conversionPattern value="%property{log4net:MODULE}"/>
</parameter>
<parameter>
<parameterName value="@p_Component" />
<dbType value="VARCHAR2" />
<size value="225" />
<!--<layout type="log4net.Layout.ExceptionLayout" />-->
<conversionPattern value="%property{log4net:COMPONENT}"/>
</parameter>
<parameter>
<parameterName value="@p_Stack_Trace " />
<dbType value="VARCHAR2" />
<size value="4000" />
<!--<layout type="log4net.Layout.PatternLayout"/>-->
<conversionPattern value="%property{log4net:STACK_TRACE}"/>
</parameter>
<parameter>
<parameterName value=" @p_Additional_Message" />
<dbType value="VARCHAR2" />
<size value="4000" />
<!--<layout type="log4net.Layout.ExceptionLayout" />-->
<conversionPattern value="%property{log4net:ADDITIONAL_MESSAGE}"/>
</parameter>
</appender>