hi,

 

i need to write an owen logger class extending log4js logger and
overwriting the debug, info, warn, error and fatal methods!

 

o.k. - i've done it like that:

 

public void debug(Object msg){

...

my operations

...

 

logger.debug(msg);  //logger is an object of log4js Logger

}

 

the problem is... i'm configuring my logger object in a properties file,
and i need to track the calling class and method (the methode who starts
the logging)... 

 

i used the patternlayouts litterals %C{1}.%M for getting the Class and
Methods names... but now MY appender is the calling class and my debug
method is the calling method... due to the command 

logger.debug(msg);  //logger is an object of log4js Logger

 

:(((

 

i've tried to replace the logger.debug(msg) thing with the code, that is
in the Logger.debug methode - hoping to get the initialli calling class
and methode... getting Nullpointers because of repository is Null... i
tryed get rid of this problem by setting the repository... but now... my
loggerobject doesnt have an appender... but it should have one... here
is the fragment of my code - can anyone help me with this?!?!

 

public void debug(Object msg){

            

...

my operations

...         

 

Logger logger = Logger.getLogger("myAppender");

 

Hierarchy hierarchy = new Hierarchy(logger);

repository = hierarchy;

      

if (repository.isDisabled(Level.DEBUG_INT)) {

  return;

}

 

if (Level.DEBUG.isGreaterOrEqual(logger.getEffectiveLevel())) {

  forcedLog(myLogger.class.getName(), Level.DEBUG, msg, null);

}

}

Reply via email to