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

  • Home
  • SEARCH
  • 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 7093715
In Process

The Archive Base Latest Questions

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

I need to catch log4net exceptions (its own exceptions not app exceptions logged by

  • 0

I need to catch log4net exceptions (its own exceptions not app exceptions logged by it). I wish there’s a way of doing it this way:

Try
    _logger.Info(response)
Catch ex As Exception
    Excepciones.HandleException(ex, "PolicyCore")
End Try

I have this code implemented and there’s no errors in compilation but i force log4net to have an error (pointing to a non existing database in the config file) and nothing is threw.
I’ve tried the listener aproach:

 <appSettings>
        <add key="log4net.Internal.Debug" value="true" />
    </appSettings>
    <system.diagnostics>
       <trace autoflush="true" indentsize="4" >
         <listeners>
           <add name="textWriterTraceListener" 
               type="System.Diagnostics.TextWriterTraceListener"
               initializeData="C:\\temp\\log4net.txt" />
           <remove name="Default" />
         </listeners>
       </trace>
    </system.diagnostics>

and it’s writing the errors to log4net.txt, the forced ones i mean.

This last aproach has a couple of drawbacks: it won’t append every error to the file, if the error is the same it doesn’t write it, i can’t get the listener to write every error to that file, only one (I don’t know how to fully configure the trace listener, it might be that). Thus it won’t append the date and hour to every line wich is a necesity for me. Finally i can’t give structure to it (xml).

Even if the listener work i need to use the try/catch aproach, since i’m using ExceptionHandling from Enterprise library to log the errors in my app.

Anyone who has faced the problem and/or has a solution?

  • 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-28T08:28:27+00:00Added an answer on May 28, 2026 at 8:28 am

    Log4net is designed not to throw any exceptions. This seems to be a good idea because it would be very bad indeed if your application fails because it cannot log. So if you need to log certain messages and need to be sure that this worked, then you should not use a log framework, but rather implement this as part of your “business logic”.

    You mention that an exception is logged only once. I think that is not true: Log4net usually disables appenders that do not work and thus there is only one exception. The AdoNetAppender for instance can be configured to re-connect to the database in case of a failure in which case you would see the same exception multiple times.

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

Sidebar

Related Questions

I need to catch ALL exceptions and errors in an iphone app. Obviously, this
I need to catch error codes in an mvc app. Is there a list
I need to catch segmentation fault in third party library cleanup operations. This happens
I need to write a delegate function that can 'wrap' some while/try/catch code around
VB 6.0 does not have any global handler.To catch runtime errors,we need to add
catch is not working because there is installed an exception handler using set_exception_handler() I
Please tell me how to use try/catch properly with boost::exception. This is one of
In my project, I need to catch the Window focus change. I have logged
I Need to catch an event in itemrenderer component dispatched from its parent i.e
I do not understand the behavior. I have such example, need to catch html

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.