Extendening/wrapping Logger?

2010-10-12 Thread s243a


The code shown bellow was given as an example of how to extend Loger what I 
don't get is why logger was made a static field. Would this mean you would need 
a separate class for every instance?


directory.  It is a bit out of date (my fault), but it includes some tips for  
extending various portions of log4j. - Paul  Paul Glezen  Consulting IT 
Specialist  IBM Software Services for WebSphere  818 539 3321  AIM: 
pfglezenibm  YIM: pfglezen  ICQ: 179406599  Please respond to Log4J 
Developers List log4j-dev at logging.apache.org To:  log4j-dev at 
logging.apache.orgcc:Subject:   How to extendLogger Class Hi   I am 
using 
Logger class in my project..BUt All the functions are of typestatic type and we 
cant override the static functions in subclasss..so how can  i extend Logger 
class.Is there anyway..Please suggest me Thanx in advanceNidhi Garg  Software 
Development Engineer (RD)Barco | Control RoomsTel +91(0) (120) 2421651(10 
Lines) Ext. 245Fax +91(0) (120) 242 1691 Hi,Try using the following 
code snippet  public class MyLogger extends Logger {  static 
Logger 
logger;  //in the constructor, create the object of Logger class   public 
RALogger(String name) { super (name); logger = this.getLogger(name); 

logger.setLevel(Level.ALL);   }//Override the methods and here you can massage 
the data as required by you  before you print it...   public void 
debug(Object 
message) {  logger.debug(message);   }   public void debug(Object 
message, Throwable t) {  logger.debug(message, t);   }   public void 
error(Object message) {  logger.error(message);   }   public void 
error(Object message, Throwable t) {  logger.error(message, t);   }
public void fatal(Object message) {  logger.fatal(message);   }   public 
void fatal(Object message, Throwable t) {  logger.fatal(message, t);   } 
 
  public void info(Object message) {  logger.info(message);   }  
public void info(Object message, Throwable t) {  logger.info(message, t); 
  
}public void warn(Object message) {  logger.warn(message);   }   
public void warn(Object message, Throwable t) {  logger.warn(message, t); 
  
}   }  Regards, Deepal Mehta
http://web.archiveorange.com/archive/v/uhq8tUYjy7IxiVqTYDg9




exception std::out_of_range in StringHelper::startsWith

2010-10-12 Thread Thorsten Schöning
Hello,

I get an out_of_range exception everytime I use a logger which name is
longer than the name of the root logger and wonder if anyone else ran
into this problem, too. We use a pretty old Borland Builder 5, may it
be an implementation issue of the stl? Reading how
basic_string::compare works for other implementations the current
startWith should work, in my opinion.

http://www.sgi.com/tech/stl/basic_string.html

I had to make the following changes:

Index: stringhelper.cpp
===
--- stringhelper.cpp(Revision 1652)
+++ stringhelper.cpp(Arbeitskopie)
@@ -79,6 +79,11 @@
 
 bool StringHelper::startsWith(const LogString s, const LogString prefix)
 {
+if (s.length()  prefix.length())
+{
+  return false;
+}
+
 return s.compare(0, prefix.length(), prefix) == 0;
 }

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning
AM-SoFT IT-Systeme - Hameln | Potsdam | Leipzig
 
Telefon: Potsdam: 0331-743881-0
E-Mail:  tschoen...@am-soft.de
Web: http://www.am-soft.de

AM-SoFT GmbH IT-Systeme, Konsumhof 1-5, 14482 Potsdam
Amtsgericht Potsdam HRB 21278 P, Geschäftsführer: Andreas Muchow