Exception Handling - logging Stack Trace

Topics: Exception Handling Application Block
Jul 9, 2008 at 12:58 PM
Hi

I am using Exception Handling Application Block with logging in a ASP.NET application.

My problem is that the "Stack Trace" in my logg file is not complete.

From the log file generated by Enterprise Library: 
....
Stack Trace :    ved Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
   ved Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src)
   ved Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
   ved Oracle.DataAccess.Client.OracleDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBeh
...

This is the complet Stack Trace I can see when stopping using Breakpoint in the code: 

ved Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
ved Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src)
ved Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
ved Oracle.DataAccess.Client.OracleDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
ved System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
ved Cinclus.Atos.DataExchange.Alarm.ErrorCodesDataAdapter.getErrorCode() i C:\telenor\atos\Cinclus.Atos.DataExchange\Alarm\ErrorCodesDataAdapter.cs:linje 29
ved Cinclus.Atos.Domain.Alarm.ErrorCodeController.getErrorCode() i C:\telenor\atos\Cinclus.Atos.Domain\Alarm\ErrorCodeController.cs:linje 16
ved error_codes.Page_Load(Object sender, EventArgs e) i c:\telenor\atos\Cinclus.Atos.Web\Alarm\error_codes.aspx.cs:linje 19
ved System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
ved System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
ved System.Web.UI.Control.OnLoad(EventArgs e)
ved System.Web.UI.Control.LoadRecursive()
ved System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


Why is not the whole Stack Trace written to the log file?

This is my code in global.asax:

        Exception ex = Server.GetLastError();
        Server.ClearError();
        try {
            bool rethrow = ExceptionPolicy.HandleException(ex.GetBaseException(), ExceptionPolicies.GLOBAL_POLICY);  // breakpoint here to inspect Stack Trace
            if (rethrow)
                Response.Write(GetErrorMsg());
        }
        catch {
            Response.Write(GetErrorMsg());
        }



bjarne
Jul 9, 2008 at 2:45 PM

Hi Bjarne,

Your log file snippet seems to be incomplete: it's cut in the middle of a type name. Is that all you get in the log file?

I suggest you look at the value of the StackTrace property in ex.GetBaseException() and compare it to what you get in the log file.

Fernando

 

Jul 9, 2008 at 3:58 PM
Hi Fernando,

Your post gave me a hint:

I found a bug in my code. Sorry to disturb you.  But thanks.

I have a "CustomTraceListener", which Substring (0,1000) the message, in order to get it stored in a database.(could not change the base right now)

I remembered that code when I read your post. Thanks.

bjarne