none
Logging in an N-Tier Web Application RRS feed

  • Question

  • Hi,

    I am about to build an N-Tier MVC Application (Presentation Layer, Business Layer, Data Access Layer).

    I am looking for advice on how I should do my logging.

    From my Presentation layer I call a class in my Business Layer and in turn call a class in my Data Access Layer; if I have exception handling  at all layers and an exception occurs in my Data Access Layer, should I log error at the Data Access Layer or should I raise the error back up the stack and catch all errors in the Presentation Layer (Application_OnError routine)?


    Thanks.


    CG

    • Moved by CoolDadTx Thursday, February 16, 2017 3:13 PM ASP.NET related
    Tuesday, February 14, 2017 11:35 AM

All replies

  • >should I raise the error back up the stack and catch all errors in the Presentation Layer

    Assuming your Tiers are all running in the same AppDomain, yes, you would want a single place to log and handle the errors.  You may have some error handling in the lower tiers, where you catch exceptions and rethrow new exceptions that would be more useful for troubleshooting.  You also might have diagnostic tracing implemented but disabled on various other components. But the decision about how to handle the error belongs to the topmost tier in the AppDomain.

    David


    Microsoft Technology Center - Dallas

    My Blog

    Tuesday, February 14, 2017 2:41 PM
  • Hi NuTech,

    Thank you for posting here.

    According to your question is more related to MVC, you could post a new thread in MVC forum for suitable support.

    The Visual C# discuss and ask the C# programming language, IDE, libraries, samples and tools.

    If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution.

    Thanks for your understanding and cooperation.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 15, 2017 7:37 AM
  • Thanks for that.

    CG

    Wednesday, February 15, 2017 8:46 AM
  • Hi NuTech,

    The experts in MVC forum will give you a solution quickly.

    Your understanding and cooperation are grateful.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 15, 2017 8:48 AM