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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:13:30+00:00 2026-06-10T18:13:30+00:00

I log my app errors. but if the logging process failed for some reasons

  • 0

I log my app errors. but if the logging process failed for some reasons ( database error , no space in the hard disk .. etc ) . how can I know that ? How to log the failed log.

example :

try{

    this_will_throw_exception();

}catch(Exception e){

    result = Log.error(e.getMessage());
    if( result == false)
        {
         // what should I do ?
        }
}
  • 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-10T18:13:32+00:00Added an answer on June 10, 2026 at 6:13 pm

    You should keep your application code simple, i.e. not to worry about logging failure and delegate the logging failure to the logger itself.

    Hence your application code should look like:

    try{
      this_will_throw_exception();
    } catch(Exception e){
      Log.error(e.getMessage());
    }
    

    Now we look at how to handle failure in logger.

    First, there is a lot of logging framework that provide appender failover. For example there us a FailoverAppender in log4j that log to secondary appender if the primary failed. http://logging.apache.org/log4j/2.x/manual/appenders.html

    If you choose to build your own logging layer for whatever reason, you may find the decorator pattern useful to build failover logger yourself.

    public interface Logger {
      boolean error(String message);
    }
    
    public DataBaseLogger implements Logger {
      ...
    }
    
    public FileLogger implements Logger {
      ...
    }
    
    public FailoverLogger implements Logger {
      private Logger primary;
      private Logger secondary;
    
      public boolean error(String message) {
        boolean succeed = primary.error(message);
        if (! succeed) {
          secondary.error("Primary logger failed");
          secondary.error(message);
          // Try to restart the primary logger, however it might be difficult.
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I received >>> THIS <<< error log from a client. I replaced the app
For debugging purposes, I would like my app to log to a java.util.logging.SocketHandler. Here's,
I trying to incorporate a simple error logging into my existing app, at the
I want my WCF service to log errors / operations, etc. I have a
My app is something like a log book. I keep an evidence of events
Our app servers (weblogic) all use log4j to log to the same file on
When I log in into my app, an async task starts executing and while
my iphone app crashes unexpectedly and looking at the crash log I can't tell
When you log out of a web app, should ALL your session be logged
I have a log in form on my app. Once a correct user name

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.