I need to create an accessible log file in our linux server. A java program is used to create a log.
In my console
Sep 11, 2014 3:03:05 PM com.gsis.bom.Log appLog
SEVERE: test 1
Sep 11, 2014 3:03:06 PM com.gsis.bom.Log appLog
INFO: test 2
Sep 11, 2014 3:03:06 PM com.gsis.bom.Log appLog
INFO: test 3
But this messages should be saved in a file in linux. For e.g. /home/logs
How can I do it?
THANK YOU
EDIT
LogManager lm = LogManager.getLogManager();
Logger logger;
FileHandler fh = new FileHandler("log_test.txt");
logger = Logger.getLogger("LoggingExample1");
lm.addLogger(logger);
logger.setLevel(Level.INFO);
fh.setFormatter(new XMLFormatter());
logger.addHandler(fh);
logger.log(Level.SEVERE, "test 1");
logger.log(Level.INFO, "test 2");
logger.log(Level.INFO, "test 3");
fh.close();
This is the code that I am using. Ok I can see it in my console. But I need the messages to be saved in a file. For example at /home/logs/log.txt in our linux server