I have written a common class for logger and used this class in another class(Server_imp) to create logs. But no data is written in the text file instead it is shown on console. What are problems with my code? actually i have to create three log files for three different servers and log the functions performed by server managers . and how i can stop data to be written on console?
public class MyLogging {
static Logger logger;
public Handler fileHandler;
SimpleFormatter plainText;
public MyLogging() throws IOException{
//instance the logger
logger = Logger.getLogger(MyLogging.class.getName());
//instance the filehandler
fileHandler = new FileHandler("D:/JAVA/assignment1/Montreallog.txt",true);
//instance formatter, set formatting, and handler
plainText = new SimpleFormatter();
fileHandler.setFormatter(plainText);
logger.addHandler(fileHandler);
}
}
//I have not copied the whole code
public class Server_imp extends UnicastRemoteObject implements ServerInterface
{
Logger logger = Logger.getLogger(MyLogging.class.getName());
public void createTRecord(String f_name,String l_name,String addr,String number,String spec,String loc)
{
logger.info("Teacher record created");
}