ENDRPrint/.svn/pristine/24/24652476f03977a143692247ad6934f0137dffe3.svn-base
2024-08-14 10:33:27 +07:00

99 lines
3.1 KiB
Plaintext

package th.co.muangthai.endrprint;
import org.apache.log4j.Logger;
import th.co.muangthai.endrprint.util.DateUtil;
import th.co.muangthai.endrprint.util.LoadLogger;
import th.co.muangthai.endrprint.util.TextContent;
import th.co.muangthai.endrprint.util.VSMUtil;
import javax.servlet.http.HttpServlet;
import java.io.File;
import java.net.InetAddress;
import java.util.Date;
public class InitialServlet extends HttpServlet {
private Logger log = Logger.getLogger(InitialServlet.class);
public InitialServlet() {
super();
}
public void init(javax.servlet.ServletConfig config) {
String ss = config.getServletContext().getServletContextName();
try {
TextContent.DEPLOYMENT_VERSION = DateUtil.toFormatString(new Date(), "yyyyMMdd-HHmmss");
//InputStream test = new FileInputStream("jdbc.properties");
try{
File f = new File(".");
//log.info("test root path : " + f.getAbsolutePath());
ClassLoader cl = getClass().getClassLoader();
//log.info("test root path : " +cl.getParent().toString());
//log.info("test root path : " +cl.getResource(""));
//log.info("test root path : " +cl.toString());
}catch (Exception e){
}
// String propFileName = "jdbc.properties";
// Properties props = new Properties();
// InputStream inputStream =
// this.getClass().getClassLoader().getResourceAsStream(propFileName);
//
// if (inputStream == null)
// {
// throw new FileNotFoundException("property file '" + propFileName
// + "' not found in the classpath");
// }
//
// props.load(inputStream);
//URL baseURL = config.getServletContext().getResource(".");
//String hostname = InetAddress.getLocalHost().getHostName();
//System.out.println("XXX _" + ss);
String hostname = InetAddress.getLocalHost().getHostName();
String path = "/LOGGING2/PRTENDR/Web/";
String newPath = path + hostname + "_" + VSMUtil.DEPLOY_NAME + ".log";
//System.out.println("XXX _" + newPath);
LoadLogger.initialLogger(newPath);
} catch (Exception e) {
log.error(e.toString(), e);
}
}
public static void main(String[] args) {
// LoadLogger.initialLogger("/test.log");
// InitialServlet inint = new InitialServlet();
// inint.initScheduler(null);
Date date = new Date(1434952019287l);
System.out.println(date);
}
// @Override
// public void contextInitialized(ServletContextEvent servletContextEvent) {
// System.out.println("XXX _" + servletContextEvent.getServletContext()..getServletContextName());
// //To change body of implemented methods use File | Settings | File Templates.
// }
//
// @Override
// public void contextDestroyed(ServletContextEvent servletContextEvent) {
// //To change body of implemented methods use File | Settings | File Templates.
// }
}