java - log4j custom logger method not getting called -


i want override error(object message, throwable t) of log4j.logger class change few things. when extend mylogger extends logger, still not call implementation of error(..) method rather super class's method getting called.

here's code

public class mylogger extends logger {      private static final string fqcn = mylogger.class.getname();       protected mylogger(string name) {         super(name);         // todo auto-generated constructor stub     }   public void error(object message, throwable t,final string codekey, final string messagekey) {         system.out.println("codekey "+codekey+" messagekey"+messagekey);         string fmessage=codekey+":"+messagekey;          if (this.repository.isdisabled(40000))             return;         if (level.error.isgreaterorequal(geteffectivelevel()))             forcedlog(fqcn, level.error, fmessage, null);     }  } 

and test class i'm trying call implementation of error(..)

public class testlogger {      protected static final mylogger log = (mylogger) mylogger.getlogger(testlogger.class);      public static void main(string[] args) {         log.error("testing log error");      } } 

i had such problem once , i've fixed way:

public class mylogger {      private logger  logger;      public mylogger(string name) throws ioexception {         logger = logger.getlogger(name);                     }      public void error(string message){         if (logger != null)              logger.error(message);     } } 

Comments

Popular posts from this blog

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -