13 Eylül 2011 Salı

logging the stacktrace

logging the stacktrace with log4j:


import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

// ......
static Logger logger = Logger.getLogger(MyClass.class);

// ......
public static void debugException(Exception ex) {
    //ex.printStackTrace();
    logger.error("An error occurred in MyClass.", ex);
}

Hiç yorum yok:

Yorum Gönder