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 6711383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:08:00+00:00 2026-05-26T08:08:00+00:00

Hi I try log expcetion on App Domain with NLog. It is WPF app

  • 0

Hi I try log expcetion on App Domain with NLog. It is WPF app with Caliburn Micro.

In MEF bootstraper I have this code:

static readonly ILog Log = LogManager.GetLog(typeof(NLogLogger));

#region Constructors

    public MefBootStrapper()
        : base()
    {
        _msgBox = new MessageBoxes();
        _doHandle = true;
    }

    static MefBootStrapper()
    {
        LogManager.GetLog = type => new NLogLogger(type);
    }


#endregion


#region Exception handling on App Domain

protected override void OnUnhandledException(object sender, 
    System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
    if (_doHandle)
    {
        Log.Error(e.Exception.InnerException);
        _msgBox.ShowException(e.Exception.InnerException);
        e.Handled = true;
    }
    else
    {
        Log.Error(e.Exception.InnerException);
        _msgBox.ShowException(e.Exception);
        e.Handled = false;
    }

}

#endregion

When I run app and throw exception from view modle class it show message box that is ok but exception is not logged to file.

I try log exception in view model calls:

something like this: Log.Error(new Exception(“4”));

This work, but If i try log exception in OnUnhandleException method it doesnt wokr. Why?

  • 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-05-26T08:08:01+00:00Added an answer on May 26, 2026 at 8:08 am

    Your problem is that the static field Log gets initialized before your static constructor runs see (Static field initialization). So you will have your Log field with the default Caliburn Nulloger initialized instead of your NLogLogger. You should move the Log field initialization into your static constructor.

    private static readonly ILog Log;
    
    static MefBootStrapper()
    {
        LogManager.GetLog = type => new NLogLogger(type);
        Log = LogManager.GetLog(typeof(NLogLogger));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code: File myDir = new File(getApplicationContext().getFilesDir().getAbsolutePath()); try { Log.i(CSV Testing
try { // Code } catch (Exception ex) { Logger.Log(Message, ex); throw; } In
I've written this to try and log onto a forum (phpBB3). import urllib2, re
I have this code to receive the caller number and do query in side
Main Activity Code. BroadcastExample.java package com.example.broadcast; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class
I have a Win32 C++ app developed in VS2005. There is a try {}
I had try to implement the send me log feature into my apps but
$(item).droppable({ drop: function(event, ui) { console.log(triggered); } }); I try to call drop by
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
Try the following code public enum Color { Blue=1, Red=2, Green=3 } public List<Color>

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.