Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9005947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:16:55+00:00 2026-06-16T01:16:55+00:00

Is there a way to configure NLog to automatically log all exceptions my application

  • 0

Is there a way to configure NLog to automatically log all exceptions my application can send? Currently I am going to all TRY/CATCH blocks and manually adding logging in the CATCH – but what if I miss some? And what if in the future someone else does

Is there a way to tell NLog to just always log all exceptions? Esspecially some that are not caught and could cause a popup?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:16:57+00:00Added an answer on June 16, 2026 at 1:16 am

    As far as I know, there is no way to confineNLog to log all exceptions.

    If all you want is to log unhandled exceptions, you could add an “UnhandledException Handler” to the AppDomain when initializing your application.
    Note that under some circumstances it may not be possible to log the error (e.g. in case of an OutOfMemory exception or something terrible).

    Note that the AppDomain also has a FirstChanceException event you can subscribe to, but this would mean that you get notified about every exception that occurs (and may be handled by the usercode) – in this are many.

    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_CurrentDomain_UnhandledException);
    
    static void AppDomain_CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
    {
        // use logger here to log the events exception object
        // before the application quits
    }
    

    Note that this will only allow you to log exceptions that cause your application to crash – you cannot prevent it to crash (therefore the name: unhandled exception).

    Another option would be to use Aspect Oriented Programming (AOP) – and introduce a Logging aspect after each method call, in case of an error. If your application uses a Layered architecture, this may be relatively easy to do (e.g. add an aspect to all calls of your business logic layer…).

    You may find a framework like PostSharp or Spring.Net useful (usually their websites provide some easy examples for that).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to configure NLog to log information per application session? As
I'm using NLog to log to file. Is there a way to configure it
Is there any way to configure Doxygen to include the log from SVN for
Is there a way to configure an application shortcut so that a Windows shell
Is there a way to configure Tomcat to die automatically if there's an error
Is there a way to configure CakePHP models to automatically set timestamps, such as
Is there a way to configure specific settings for my web application that will
Is there a way to configure spring application context so it will initialize the
Is there a way to configure SVN to send me email when a specific
Is there any way to configure TFS to not mark all files as read

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.