summaryrefslogtreecommitdiffstats
path: root/openo-portal
diff options
context:
space:
mode:
author“shentao” <shentao@chinamobile.com>2016-11-09 18:48:07 +0800
committer“shentao” <shentao@chinamobile.com>2016-11-09 18:48:07 +0800
commitbbef3ed82ca4faee5b19ba820dae11e86054b291 (patch)
tree3ef09892100cfb97f4ba6e595e58cd2a4b0cb242 /openo-portal
parent1799c18416ccb7e2bac1fd6aabcb74521f65da24 (diff)
GSO-104
Change-Id: Iaea5ab5d93cbaf6d7c18bd93823695768f59f897 Signed-off-by: “shentao” <shentao@chinamobile.com>
Diffstat (limited to 'openo-portal')
-rw-r--r--openo-portal/portal-package/pom.xml22
-rw-r--r--openo-portal/portal-package/src/main/java/org/openo/portal/system/RegisterService.java20
-rw-r--r--openo-portal/portal-package/src/main/java/org/openo/portal/system/SystemListener.java11
-rw-r--r--openo-portal/portal-package/src/main/resources/logback.xml102
4 files changed, 143 insertions, 12 deletions
diff --git a/openo-portal/portal-package/pom.xml b/openo-portal/portal-package/pom.xml
index baf14fb9..ac309936 100644
--- a/openo-portal/portal-package/pom.xml
+++ b/openo-portal/portal-package/pom.xml
@@ -28,10 +28,32 @@
<properties>
<packagename>openoui</packagename>
+ <version.logback>1.1.2</version.logback>
+ <version.slf4j>1.7.6</version.slf4j>
</properties>
<dependencies>
<dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>${version.logback}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>${version.logback}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-access</artifactId>
+ <version>${version.logback}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${version.slf4j}</version>
+ </dependency>
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
diff --git a/openo-portal/portal-package/src/main/java/org/openo/portal/system/RegisterService.java b/openo-portal/portal-package/src/main/java/org/openo/portal/system/RegisterService.java
index 01ba3526..a1a06f0a 100644
--- a/openo-portal/portal-package/src/main/java/org/openo/portal/system/RegisterService.java
+++ b/openo-portal/portal-package/src/main/java/org/openo/portal/system/RegisterService.java
@@ -34,9 +34,13 @@ import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.openo.portal.bean.MsbRegisterBean;
import org.openo.portal.bean.ServiceNodeBean;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class RegisterService {
+ private final static Logger logger = LoggerFactory.getLogger(RegisterService.class);
+
public static HashMap<String, String> msbHostMap = new HashMap<String, String>();
public static List<HashMap<String, String>> registerList = new ArrayList<HashMap<String, String>>();
@@ -70,13 +74,12 @@ public class RegisterService {
registerBean.setLb_policy(registerInfo.get("lb_policy"));
JSONObject registerObj = JSONObject.fromObject(registerBean);
- String registerResponse = registerPortalService(url, registerObj, "");
- // TODO
- System.out.println(registerResponse);
+ String registerResponse = registerPortalService(registerBean.getServiceName(), url, registerObj, "");
}
+ logger.info("open-o portal register task succeeded.");
} catch (Exception e){
- // TODO
- e.printStackTrace();
+ logger.error("open-o portal register task failed.");
+ logger.error(e.getMessage());
}
}
@@ -107,7 +110,7 @@ public class RegisterService {
}
}
- private static String registerPortalService(String url, JSONObject json, String token) {
+ private static String registerPortalService(String serviceName, String url, JSONObject json, String token) {
DefaultHttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
String response = null;
@@ -132,9 +135,10 @@ public class RegisterService {
response = null;
}
}
+ logger.info("register task [" + serviceName + "] completed successfully.");
} catch (Exception e) {
- // TODO
- e.printStackTrace();;
+ logger.error("register task [" + serviceName + "] failed because of errors.");
+ logger.error(e.getMessage());
}
return response;
diff --git a/openo-portal/portal-package/src/main/java/org/openo/portal/system/SystemListener.java b/openo-portal/portal-package/src/main/java/org/openo/portal/system/SystemListener.java
index 05447232..eadb77a1 100644
--- a/openo-portal/portal-package/src/main/java/org/openo/portal/system/SystemListener.java
+++ b/openo-portal/portal-package/src/main/java/org/openo/portal/system/SystemListener.java
@@ -20,17 +20,20 @@ import java.io.File;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class SystemListener implements ServletContextListener {
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
public void contextDestroyed(ServletContextEvent sce) {
}
public void contextInitialized(ServletContextEvent servletContextEvent) {
- // TODO
- System.out.println("portal register task begin");
+ logger.info("open-o portal register task begin.");
String registerFilePath = SystemListener.class.getClassLoader().getResource("").getPath() + "portalConfig" + File.separator + "msb_register.xml";
RegisterService.registerMsb(registerFilePath);
- // TODO
- System.out.println("portal register task ended.");
+ logger.info("open-o portal register task ended.");
}
}
diff --git a/openo-portal/portal-package/src/main/resources/logback.xml b/openo-portal/portal-package/src/main/resources/logback.xml
new file mode 100644
index 00000000..bf07d3b2
--- /dev/null
+++ b/openo-portal/portal-package/src/main/resources/logback.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<configuration debug="false" scan="true" scanPeriod="30 seconds">
+ <property name="projectName" value="openoui"/>
+ <property name="logDir" value="../webapps/openoui/openoui_log"/>
+ <property name="maxHistory" value="30"/>
+ <timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/>
+
+ <appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>
+ %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger - %msg%n
+ </pattern>
+ </encoder>
+ </appender>
+
+ <appender name="errorAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>ERROR</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/error/error.%d{yyyy-MM}.log</fileNamePattern>
+ <maxHistory>${maxHistory}</maxHistory>
+ </rollingPolicy>
+ <encoder>
+ <pattern>
+ %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger - %msg%n
+ </pattern>
+ </encoder>
+ </appender>
+
+ <appender name="warnAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>WARN</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/warn/warn.%d{yyyy-MM}.log</fileNamePattern>
+ <maxHistory>${maxHistory}</maxHistory>
+ </rollingPolicy>
+ <encoder>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="infoAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>INFO</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/info/info.%d{yyyy-MM}.log</fileNamePattern>
+ <maxHistory>${maxHistory}</maxHistory>
+ </rollingPolicy>
+ <encoder>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="debugAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>DEBUG</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/debug/debug.%d{yyyy-MM}.log</fileNamePattern>
+ <maxHistory>${maxHistory}</maxHistory>
+ </rollingPolicy>
+ <encoder>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="traceAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>TRACE</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/trace/trace.%d{yyyy-MM}.log</fileNamePattern>
+ <maxHistory>${maxHistory}</maxHistory>
+ </rollingPolicy>
+ <encoder>
+ <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root>
+ <level value="info"/>
+ <appender-ref ref="consoleAppender"/>
+ <appender-ref ref="errorAppender"/>
+ <appender-ref ref="warnAppender"/>
+ <appender-ref ref="infoAppender"/>
+ <appender-ref ref="debugAppender"/>
+ <appender-ref ref="traceAppender"/>
+ </root>
+</configuration>