.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Add Stack Trace in trace.log file using Enterprise library 5.0

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net


I am facing one issue while using trace.log file for logging the exceptions. I need to get the stack trace with other exception information. But stack trace is not available with provide enterprise library 5.0 exception logging template. Is there any way I can add this.

Also I want to genrate seprate trace.log file for every day.


View Complete Post

More Related Resource Links

remove stack trace , Additional Info, from log file


i am using belowcode in web.config 

<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
      <add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName=".\Logs\jeejix_error.log" footer="------------Error End----------------------------" formatter="Text Formatter" header="---------Error Start-------------------------------" rollFileExistsBehavior="Increment" rollInterval="Day" rollSizeKB="50" />
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken

Help- Enterprise Library Logging Block (Database trace listener)



I'm new to enterprise application blocks. I'm trying to use database trace listener to write the logs to Database. Can someone help me on this .

I would apprciate your response.







Database Trace Listener in the Enterprise Library doesnt work


I am having a problem on the Database Trace Listener in the Enterprise Library. I have created the database trace listener and and the procedures and tables, but the data is not logged in the table.  Thank you very much.

I need to log data in file and db both. If i comment the database listener, the file listener works but it doesnt work with the database listener. And the database listener doesnt work in any case. Connection string has no problem.

Here's my web.config:

<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="GeneralLog" logWarningsWhenNoCategoriesMatch="true">
      <add databaseInstanceName="WEBJunctionDbServer" writeLogStoredProcName="WriteLog"
          addCategoryStoredProcName="AddCategory" formatter="Text Formatter"
          listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=, Culture=neutral, PublicKeyToken=null"
          traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Form

Debugging Stack Trace

I have a VB.net dll that gets loaded as an add on to AutoCAD. I have it setup so that all exceptions get logged in a database table, along with the stack trace. The dll is on several users computers now for testing. On some computers, the stack trace returns line numbers, which is very helpful. Other computers do not give the line numbers on the stack trace for some reason. All computers are automatically updated, so they always have the same version of the dll. The DLL is built with full debug information. Do you know why some computers would return the line numbers and others would not?  

How to know the error cause using the stack trace in asp.net mvc

I am getting following error The model item passed into the dictionary is of type 'Helpers.PaginatedList`1[EntityLayer.Test]', but this dictionary requires a model item of type 'Helpers.PaginatedList`1[EntityLayer.Test]' And the stack trace is as follows at System.Web.Mvc.ViewDataDictionary`1.SetModel(Object value) at System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary) at System.Web.Mvc.ViewUserControl`1.SetViewData(ViewDataDictionary viewData) at System.Web.Mvc.WebFormView.RenderViewUserControl(ViewContext context, ViewUserControl control) at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass14.<InvokeActionResultWithFilters>b__11() at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)\n Inner Exception:\n I am not able to get what is the problem here?Can anybody help in this?

Konesans Trace File Source adapter


Found the handy Konesans Trace File Source adapter that allows reading of SQL Profiler trace (.trc) files, and it works well. The adapter has properties that allow for Variable-based filename property interpretation...however being a total SSIS noob, I am not familiar how to set up the variables so that it will read from a series of files in a directory. The method I am familiar with, of using a ForEach container doesnt really work because the adapter itself does not rely on a connection manager, and I am unable to set the variable name for it via an expression.

Anyone out there using this tool or have some pointers?




Couple of questions about WinDbg/Adplus stack trace output

I'm hoping someone can answer a couple of questions I have about the stack trace output of threads in WinDbg/DebugDiag (from an Adplus dmp file)

Im getting a lot of steps in thread stack traces such as:

My question is, should the hex value (I'm guessing) be pointing to a more easily recognisable component in the specified Dll? In my searching around this I have noticed some people pasting similar to the above with method names instead of the hex, which would be a lot more useful to me if I was able to get that.

I've also noticed a few instances like <Unloaded_ure.dll>+1d7a294  
Can anyone point to what these mean?


Stack Trace differences on 64-bit system vs 32-bit

I'm seeing differences in the stack trace produced from exceptions thrown in the same program running on two different systems (I've run it on a 32 bit XP system and a 64 bit Windows 2008 system).

Here's the program:
//when this #define is commented out, the methodsA-D don't
// have a side effect (setting a static variable),
// and this seems to cause the 64 bit stack traces to differ.
//#define methods_have_side_effects

using System;
using System.Reflection;

namespace StackTraceTest
    public class Program
        public static int some_side_effect;

        public static void Main(string[] args)
            try{ methodA(); }
            catch(Exception e)
            { Console.WriteLine(e + e.StackTrace); }

                Type t = Type.GetType("StackTraceTest.Program");
                t.GetMethod("methodA", BindingFlags.Static | BindingFlags.Public).Invoke(null, new object[] { });
            catch (Exception e)
            { Console.WriteLine(e + e.StackTrace); }

cannot get full stack trace exceptions from server if I am using a CustomChannel even if CustomError



When I am implementing my own custom channel for .net remote object calls, I cannot get full stack trace on exceptions from the server.

Problem description:

I have a server with the following remote class:

 public class MyClassRemote : MarshalByRefObject   
 public string GetServerString()       
 {                        throw new NullReferenceException("my exception");           
 return "sample message";        

at start up, the server has the following initialization code:

RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
MyChannel myChannel = new MyChannel(myChannelSettings);
ChannelServices.RegisterChannel(myChannel, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyClassRemote), typeof(MyClassRemote).FullName, WellKnownObjectMode.SingleCall);
Note: Keep in mind that I did set CustomErrorsMode.Off on the server side. So, I should get all the

Trace Log generating huge file with "ManagedObjectFactory failed to GetObject."



I have MOSS 2007 installed with two Front-end server, have problem from the day when I turn on "Diagnostic logging > Trace Log " from SharePoint Administration.


My setting for Trace log is  like this


Category = All


Least critical event to report to the event log = None

Getting error...what does stack trace indicate?...




I have the following code:

'Page_Load on ChooseTime_aspx

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not (Page.IsPostBack) Then
            If Session("orderfortoday") = 0 Then
                Button_today.Visible = False

            End If

            Panel_SuccessfulOrder.Visible = False
            Panel_EmailConfirm.Visible = False
            Panel_EmailInput.Visible = False

            Dim skipWeekend1 As DateTime = SkipWeekendDay1()
            Dim skipWeekend2 As DateTime = SkipWeekendDay2()
            Session("Day1_AvoidWeekends") = skipWeekend1.ToString("MM/dd/yyyy")

Logging logevents to flat file using Microsoft Enterprise Library



I Want to log logevents to text file using Microsoft enterprise library, but i could not find any decant tutorial for same.

If you guys have any tutorial or link, please pass it to me.






Problem redirect debug output to a file using trace listener


I have created a debug listener to redirect the output from the Debug/Console window to a file(with a call stack), using the following code:

void SomeMethod()
    // Create a file for output .txt.
    Stream debugFile = File.Create(fileName);

    // create TextWriterTraceListener named "file"
    TextWriterTraceListener debugWriter = new TextWriterTraceListener(debugFile, "file");

    // add to debug listeners
    // set callstack to be shown
    Debug.Listeners["file"].TraceOutputOptions |= TraceOptions.Callstack;
    // set auto-flush
    Debug.AutoFlush = true;

but the output won't redirect to the file I specified, it is always empty. I am calling this from the constructor in my main form. Is the place where I'm calling it from a problem?

What I am trying to achieve here is to have the exceptions from the Debug output window placed in a file with a call stack, so that I can find them and correct them.

Anyone have any ideas?

Bojan Skr

Upload a File to a SharePoint Document Library - Part I

The following helper class demonstrates a few techniques that allow documents to be uploaded to a SharePoint document library programmatically without using the API or a custom web service. You don't need to specify a document library name, and it will create any folders specified in the URL as required. File meta data will be updated if any properties are passed.

MVC + Enterprise Library


Not a MVC specific question, but as that's what I'm doing I thought I'll post here.

While looking into the source code of an existing application, I stumbled upon MS Enterprise Library, and as I only heard about these "application block" stuff decided to look into it.

From the theory it sounds like a pretty usefull thing and it made me wonder if other's are using it succesfully along with MVC projects (I know they are not really related!)?

Pro's and Con's? 

I like the database block, as I did not get to any real database development the last 1.5 years, for instance. (Bad excuse I know).  Having an IoC thrown in there (Unity) sounds like I can pretty much stop using 3rd party libraries like I do now all over the place.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend