Esempio n. 1
0
 /**
  * Main entry point for getting an Logger for a given name. Calls getLogger to return the instance
  * of Logger from our custom Factory.
  *
  * <p>Note that if the log4j system has not been setup correctly, meaning the LoggerFactory
  * subclass has not been correctly put in place, then RuntimeException will be thrown.
  *
  * @param name to create the logger for
  * @return Logger for the given name.
  */
 public static ERXLogger getERXLogger(String name) {
   Logger logger = ERXLogger.getLogger(name);
   if (logger != null && !(logger instanceof ERXLogger)) {
     ERXLogger.configureLoggingWithSystemProperties();
     logger = ERXLogger.getLogger(name);
   }
   if (logger != null && !(logger instanceof ERXLogger)) {
     throw new RuntimeException(
         "Can't load Logger for \""
             + name
             + "\" because it is not of class ERXLogger but \""
             + logger.getClass().getName()
             + "\". Let your Application class inherit from ERXApplication or call ERXLog4j.configureLogging() statically the first thing in your app. \nAlso check if there is a \"log4j.loggerFactory=er.extensions.Logger$Factory\" line in your properties.");
   }
   return (ERXLogger) logger;
 }
Esempio n. 2
0
 /**
  * 更新排号
  *
  * @return
  */
 public String updateQueue() {
   HttpServletResponse response = ServletActionContext.getResponse();
   /*
    * 在调用getWriter之前未设置编码(既调用setContentType或者setCharacterEncoding方法设置编码),
    * HttpServletResponse则会返回一个用默认的编码(既ISO-8859-1)编码的PrintWriter实例。这样就会
    * 造成中文乱码。而且设置编码时必须在调用getWriter之前设置,不然是无效的。
    * */
   response.setContentType("text/html;charset=utf-8");
   Writer out;
   String result;
   try {
     out = response.getWriter();
     result = queueService.updateQueue(queue);
     logger.info("更新排号==================:" + result);
     out.write(result);
     out.flush();
     out.close();
   } catch (Exception e) {
     logger.error(logger.getClass().getName() + "更新排号异常:" + e.getMessage());
     return this.ERROR;
   }
   return this.SUCCESS;
 }