1 16 package net.sf.jftp.system.logging; 17 18 19 import org.apache.log4j.*; 20 21 import java.io.PrintWriter ; 22 import java.io.StringWriter ; 23 24 25 public class Log4JLogger implements Logger 26 { 27 private Category cat = Category.getInstance("jftp"); 28 29 public Log4JLogger() 30 { 31 BasicConfigurator.configure(); 32 } 33 34 private String stacktrace(Throwable throwable) 35 { 36 StringWriter out = new StringWriter (); 37 throwable.printStackTrace(new PrintWriter (out)); 38 39 return (throwable.toString()); 40 } 41 42 public void debug(String msg) 43 { 44 cat.debug(msg); 45 } 46 47 public void debugRaw(String msg) 48 { 49 cat.debug(msg); 50 } 51 52 public void debug(String msg, Throwable throwable) 53 { 54 cat.debug(msg); 55 cat.debug(stacktrace(throwable)); 56 } 57 58 public void warn(String msg) 59 { 60 cat.warn(msg); 61 } 62 63 public void warn(String msg, Throwable throwable) 64 { 65 cat.warn(msg); 66 cat.warn(stacktrace(throwable)); 67 } 68 69 public void error(String msg) 70 { 71 cat.error(msg); 72 } 73 74 public void error(String msg, Throwable throwable) 75 { 76 cat.error(msg); 77 cat.error(stacktrace(throwable)); 78 } 79 80 public void info(String msg) 81 { 82 cat.info(msg); 83 } 84 85 public void info(String msg, Throwable throwable) 86 { 87 cat.info(msg); 88 cat.info(stacktrace(throwable)); 89 } 90 91 public void fatal(String msg) 92 { 93 cat.fatal(msg); 94 } 95 96 public void fatal(String msg, Throwable throwable) 97 { 98 cat.fatal(msg); 99 cat.fatal(stacktrace(throwable)); 100 } 101 } 102 | Popular Tags |