Now there is a change in demand, there are several classes in the app to record their respective information, requiring records in different files, and the content is different, as mentioned above, add a few Logger
STEP1) Modify the configuration file
XML Version = "1.0" encoding = "UTF-8"?>
2) STEP2 Modify Logger Package
/ * * Created on 2005-4-23 * * Todo to change the template for this generated file go to * window - preferences - java - code style - code templates * / package gasturbine.model.util;
Import org.apache.log4j.logger; import org.apache.log4j.xml.domconfigurator;
/ ** * @Author pw * * * / public class syslog {static logger logger = logger.getrootlogger (); static {domconfigurator.configure ("classes / log4j.xml");}
Public Static Void Debug (Object O) {Logger.debug (O);
} Public static void debug (double d) {logger.debug (" d);
} Public static void info (Object O, String Name) {logger.getlogger (name) .info (o);} public static void info (double d, string name) {logger.getlogger (name) .info (" " d);
}
}
3) Call of STEP3 client
Code pieces
Syslog.info (sb.toString (), "humidier");
Syslog.info (sb.toString (), "Cooler1");
Syslog.info (sb.toString (), "Cooler2");