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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:38:19+00:00 2026-06-15T17:38:19+00:00

I want to extend Log4j Logger for a special purpose. Here is the class

  • 0

I want to extend Log4j Logger for a special purpose. Here is the class that I have written:

package com.edfx.adb.common.logger;

import javax.faces.application.ProjectStage;
import javax.faces.context.FacesContext;

import org.apache.log4j.LogManager;

public final class Logger extends org.apache.log4j.Logger {

    protected Logger(String name) {
        super(name);
    }

    public static org.apache.log4j.Logger getLogger(String name) {
        return LogManager.getLogger(name);
    }

    @Override
    public void debug(Object message) {
        if (isDebugEnable()) {
            super.debug(message);
        }
    }

    @Override
    public void debug(Object message, Throwable throwable) {
        if (isDebugEnable()) {
            super.debug(message, throwable);
        }
    }

    private boolean isDebugEnable() {
        return FacesContext.getCurrentInstance().isProjectStage(ProjectStage.Development);
    }
}

And I am calling it as:

protected final Logger log = (Logger) Logger.getLogger(getClass());

But I am getting exception:

Caused by: java.lang.ClassCastException: org.jboss.logmanager.log4j.BridgeLogger cannot be cast to com.edfx.adb.common.logger.Logger
        at com.edfx.adb.web.controller.BaseWebController.<init>(BaseWebController.java:18) [classes:]
        at com.edfx.adb.web.controller.AuthController.<init>(AuthController.java:27) [classes:]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.7.0_09]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [rt.jar:1.7.0_09]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.7.0_09]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525) [rt.jar:1.7.0_09]
        at java.lang.Class.newInstance0(Class.java:372) [rt.jar:1.7.0_09]
        at java.lang.Class.newInstance(Class.java:325) [rt.jar:1.7.0_09]
        at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:188) [jsf-impl-2.1.7-jbossorg-2.jar:]
  • 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-15T17:38:20+00:00Added an answer on June 15, 2026 at 5:38 pm

    I don’t see why you are trying to extend the Logger, try extending an AppenderSkeleton instead, which really is what is doing all the job. And then add that Appender to your config

    public class MyAppender extends AppenderSkeleton {
        ...
    }
    

    And then add in your config:

    log4j.rootLogger=MyApp
    log4j.appender.MyApp=com.mypackage.MyAppender
    

    I have tried this myself and it works like a charm.

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

Sidebar

Related Questions

I have a class PlaylistTrack that I want to extend class Song. When I
I want to extend the IEnumerable class but only for types that can be
I have a Django template that I want to extend in multiple places. In
I have a SVG file that I want to extend by adding onclick handlers
Folks I have a sealed class as follows. I want to extend this sealed
I want extend class which have final constructor (in my case it's SimpleXMLElement), but
So I want to extend the dictionary class. Everything works so far except that
I want to extend my EF class with additional property that would come from
I want to extend a class which is implemented in Java. Here is an
I want to extend NSSlider class to have an output textfield appended to it.

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.