Refactor logging to use slf4j 23/26623/1
authorOndrej Tomcik <ondrej.tomcik@kistler.com>
Mon, 29 Jan 2018 09:12:35 +0000 (10:12 +0100)
committerPeter Rafaj <peter.rafaj@kistler.com>
Mon, 30 Jul 2018 07:00:09 +0000 (09:00 +0200)
Change-Id: I46abd4650fbca5d9d6f0f2b5278ce14d850e2549
Signed-off-by: Peter Rafaj <peter.rafaj@kistler.com>
52 files changed:
cloud/account/src/main/java/org/iotivity/cloud/accountserver/AccountServer.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/db/MongoDB.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/oauth/Github.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/oauth/Google.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/oauth/OAuthProviderFactory.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/account/AccountManager.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/account/AccountResource.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/acl/group/GroupAclManager.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/acl/group/GroupBrokerManager.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/acl/group/GroupManager.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/acl/id/Acl.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/acl/id/AclManager.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/credprov/cert/CertificateConstants.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/credprov/cert/CertificateResource.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/credprov/cert/CertificateStorage.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/credprov/crl/CrlManager.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/resources/credprov/crl/CrlResource.java
cloud/account/src/main/java/org/iotivity/cloud/accountserver/x509/cert/CSRParser.java
cloud/account/src/main/resources/logback.xml [new file with mode: 0644]
cloud/account/src/test/java/org/iotivity/cloud/accountserver/resources/acl/group/GroupAclManagerTest.java
cloud/interface/src/main/java/org/iotivity/cloud/ciserver/CloudInterfaceServer.java
cloud/interface/src/main/java/org/iotivity/cloud/ciserver/DeviceServerSystem.java
cloud/interface/src/main/resources/logback.xml [new file with mode: 0644]
cloud/interface/src/test/java/org/iotivity/cloud/ciserver/DeviceServerSystemTest.java
cloud/messagequeue/src/main/java/org/iotivity/cloud/mqserver/MessageQueueServer.java
cloud/messagequeue/src/main/java/org/iotivity/cloud/mqserver/MessageQueueUtils.java
cloud/messagequeue/src/main/java/org/iotivity/cloud/mqserver/kafka/KafkaCommonWrapper.java
cloud/messagequeue/src/main/java/org/iotivity/cloud/mqserver/kafka/KafkaConsumerWrapper.java
cloud/messagequeue/src/main/java/org/iotivity/cloud/mqserver/kafka/KafkaProducerWrapper.java
cloud/messagequeue/src/main/resources/logback.xml [new file with mode: 0644]
cloud/pom.xml
cloud/resourcedirectory/src/main/java/org/iotivity/cloud/rdserver/ResourceDirectoryServer.java
cloud/resourcedirectory/src/main/java/org/iotivity/cloud/rdserver/db/MongoDB.java
cloud/resourcedirectory/src/main/java/org/iotivity/cloud/rdserver/resources/directory/RDManager.java
cloud/resourcedirectory/src/main/java/org/iotivity/cloud/rdserver/resources/directory/rd/ResourceDirectoryResource.java
cloud/resourcedirectory/src/main/java/org/iotivity/cloud/rdserver/resources/presence/PresenceManager.java
cloud/resourcedirectory/src/main/resources/logback.xml [new file with mode: 0644]
cloud/stack/pom.xml
cloud/stack/src/main/java/org/iotivity/cloud/base/ServerSystem.java
cloud/stack/src/main/java/org/iotivity/cloud/base/connector/CoapClient.java
cloud/stack/src/main/java/org/iotivity/cloud/base/connector/CoapConnector.java
cloud/stack/src/main/java/org/iotivity/cloud/base/device/CoapDevice.java
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/coap/CoapDecoder.java
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/coap/CoapLogHandler.java
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/coap/websocket/WebSocketFrameHandler.java
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/http/HCProxyHandler.java
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/http/HCProxyProcessor.java
cloud/stack/src/main/java/org/iotivity/cloud/base/protocols/http/HttpLogHandler.java
cloud/stack/src/main/java/org/iotivity/cloud/base/server/HttpServer.java
cloud/stack/src/main/java/org/iotivity/cloud/base/server/Server.java
cloud/stack/src/main/java/org/iotivity/cloud/util/Log.java [deleted file]
cloud/stack/src/main/java/org/iotivity/cloud/util/WebsocketLog.java [deleted file]

index 8e14660..22048db 100644 (file)
@@ -24,6 +24,8 @@ package org.iotivity.cloud.accountserver;
 import java.net.InetSocketAddress;
 import java.util.Scanner;
 
 import java.net.InetSocketAddress;
 import java.util.Scanner;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.accountserver.db.AccountDBManager;
 import org.iotivity.cloud.accountserver.resources.account.AccountResource;
 import org.iotivity.cloud.accountserver.resources.account.session.SessionResource;
 import org.iotivity.cloud.accountserver.db.AccountDBManager;
 import org.iotivity.cloud.accountserver.resources.account.AccountResource;
 import org.iotivity.cloud.accountserver.resources.account.session.SessionResource;
@@ -37,7 +39,6 @@ import org.iotivity.cloud.accountserver.resources.credprov.crl.CrlResource;
 import org.iotivity.cloud.base.ServerSystem;
 import org.iotivity.cloud.base.resource.CloudPingResource;
 import org.iotivity.cloud.base.server.CoapServer;
 import org.iotivity.cloud.base.ServerSystem;
 import org.iotivity.cloud.base.resource.CloudPingResource;
 import org.iotivity.cloud.base.server.CoapServer;
-import org.iotivity.cloud.util.Log;
 
 /**
  *
 
 /**
  *
@@ -45,25 +46,21 @@ import org.iotivity.cloud.util.Log;
  *
  */
 public class AccountServer {
  *
  */
 public class AccountServer {
-
-    private static int     coapServerPort;
-    private static boolean tlsMode;
-    private static String  databaseHost;
-    private static String  webLogHost;
+    private final static Logger     Log                 = LoggerFactory.getLogger(AccountServer.class);
+    private static int              coapServerPort;
+    private static boolean          tlsMode;
+    private static String           databaseHost;
+    private static String           webLogHost;
 
     public static void main(String[] args) throws Exception {
 
     public static void main(String[] args) throws Exception {
-        System.out.println("-----Account SERVER-----");
-        Log.Init();
+        Log.info("Starting Account Server");
 
         if (!parseConfiguration(args)) {
 
         if (!parseConfiguration(args)) {
-            Log.e("\nCoAP-server <Port> Database <Address> <Port> TLS-mode <0|1> are required. WebSocketLog-Server <Addres> <Port> is optional.\n"
+            Log.error("\nCoAP-server <Port> Database <Address> <Port> TLS-mode <0|1> are required.\n"
                     + "ex) " + Constants.DEFAULT_COAP_PORT
                     + " 127.0.0.1 27017 0\n");
             return;
         }
                     + "ex) " + Constants.DEFAULT_COAP_PORT
                     + " 127.0.0.1 27017 0\n");
             return;
         }
-        if (webLogHost != null)
-            Log.InitWebLog(webLogHost,
-                    AccountServer.class.getSimpleName().toString());
 
         AccountDBManager.createInstance(databaseHost);
 
 
         AccountDBManager.createInstance(databaseHost);
 
@@ -103,18 +100,15 @@ public class AccountServer {
 
     private static boolean parseConfiguration(String[] args) {
         // configuration provided by arguments
 
     private static boolean parseConfiguration(String[] args) {
         // configuration provided by arguments
-        if (args.length == 4 || args.length == 6) {
+        if (args.length == 4) {
             coapServerPort = Integer.parseInt(args[0]);
             databaseHost = args[1] + ":" + args[2];
             tlsMode = Integer.parseInt(args[3]) == 1;
             coapServerPort = Integer.parseInt(args[0]);
             databaseHost = args[1] + ":" + args[2];
             tlsMode = Integer.parseInt(args[3]) == 1;
-            if (args.length == 6)
-                webLogHost = args[4] + ":" + args[5];
             return true;
         }
         // configuration provided by docker env
         String tlsModeEnv = System.getenv("TLS_MODE");
         if (tlsModeEnv != null) {
             return true;
         }
         // configuration provided by docker env
         String tlsModeEnv = System.getenv("TLS_MODE");
         if (tlsModeEnv != null) {
-
             coapServerPort = Integer.parseInt(System.getenv("COAP_PORT"));
             databaseHost = System.getenv("MONGODB_ADDRESS") + ":"
                     + System.getenv("MONGODB_PORT");
             coapServerPort = Integer.parseInt(System.getenv("COAP_PORT"));
             databaseHost = System.getenv("MONGODB_ADDRESS") + ":"
                     + System.getenv("MONGODB_PORT");
index 83dfb78..f54dca9 100644 (file)
@@ -29,8 +29,9 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
 import java.util.Map.Entry;
 import java.util.Set;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.bson.Document;
 import org.bson.Document;
-import org.iotivity.cloud.util.Log;
 
 import com.mongodb.MongoClient;
 import com.mongodb.client.MongoCollection;
 
 import com.mongodb.MongoClient;
 import com.mongodb.client.MongoCollection;
@@ -45,9 +46,9 @@ import com.mongodb.client.result.DeleteResult;
  *
  */
 public class MongoDB {
  *
  */
 public class MongoDB {
-
-    private MongoClient   mongoClient = null;
-    private MongoDatabase db          = null;
+    private final static Logger     Log             = LoggerFactory.getLogger(MongoDB.class);
+    private MongoClient             mongoClient     = null;
+    private MongoDatabase           db              = null;
 
     /**
      * API creating MongoClient and initializing MongoDatabase
 
     /**
      * API creating MongoClient and initializing MongoDatabase
@@ -142,7 +143,7 @@ public class MongoDB {
 
             } else {
 
 
             } else {
 
-                Log.w("DB insert failed due to duplecated one.");
+                Log.warn("DB insert failed due to duplecated one.");
                 return false;
             }
 
                 return false;
             }
 
@@ -218,7 +219,7 @@ public class MongoDB {
 
         if (collection.findOneAndReplace(filter, record) == null) {
 
 
         if (collection.findOneAndReplace(filter, record) == null) {
 
-            Log.w("DB updateX509CRL failed due to no matched record!");
+            Log.warn("DB updateX509CRL failed due to no matched record!");
             return false;
         }
 
             return false;
         }
 
@@ -249,7 +250,7 @@ public class MongoDB {
             DeleteResult result = collection.deleteMany(record);
 
             if (result.getDeletedCount() == 0) {
             DeleteResult result = collection.deleteMany(record);
 
             if (result.getDeletedCount() == 0) {
-                Log.w("DB delete failed due to no mached record!");
+                Log.warn("DB delete failed due to no mached record!");
                 return false;
             }
 
                 return false;
             }
 
@@ -342,7 +343,7 @@ public class MongoDB {
         MongoCollection<Document> collection = db.getCollection(tableName);
         MongoCursor<Document> cursor = collection.find().iterator();
 
         MongoCollection<Document> collection = db.getCollection(tableName);
         MongoCursor<Document> cursor = collection.find().iterator();
 
-        Log.i("<" + tableName + ">");
+        Log.info("<" + tableName + ">");
 
         HashMap<String, Object> records = null;
         int index = 0;
 
         HashMap<String, Object> records = null;
         int index = 0;
@@ -351,7 +352,7 @@ public class MongoDB {
             Document doc = cursor.next();
             records = convertDocumentToHashMap(doc);
 
             Document doc = cursor.next();
             records = convertDocumentToHashMap(doc);
 
-            Log.i("[" + index + "] " + records.toString());
+            Log.info("[" + index + "] " + records.toString());
             index++;
         }
 
             index++;
         }
 
index 73abb96..e74be22 100644 (file)
@@ -23,6 +23,8 @@ package org.iotivity.cloud.accountserver.oauth;
 
 import java.util.HashMap;
 
 
 import java.util.HashMap;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.apache.oltu.oauth2.client.OAuthClient;
 import org.apache.oltu.oauth2.client.URLConnectionClient;
 import org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest;
 import org.apache.oltu.oauth2.client.OAuthClient;
 import org.apache.oltu.oauth2.client.URLConnectionClient;
 import org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest;
@@ -38,7 +40,6 @@ import org.iotivity.cloud.accountserver.db.TokenTable;
 import org.iotivity.cloud.accountserver.db.UserTable;
 import org.iotivity.cloud.base.exception.ServerException.InternalServerErrorException;
 import org.iotivity.cloud.util.JSONUtil;
 import org.iotivity.cloud.accountserver.db.UserTable;
 import org.iotivity.cloud.base.exception.ServerException.InternalServerErrorException;
 import org.iotivity.cloud.util.JSONUtil;
-import org.iotivity.cloud.util.Log;;
 
 /**
  *
 
 /**
  *
@@ -48,6 +49,7 @@ import org.iotivity.cloud.util.Log;;
  */
 public class Github implements OAuthProvider {
 
  */
 public class Github implements OAuthProvider {
 
+    private final static Logger Log          = LoggerFactory.getLogger(Github.class);
     // do not use 'client_id' and 'secret' variables.
     // should use values that are obtained from github.
     final static private String client_id    = "ea9c18f540323b0213d0";
     // do not use 'client_id' and 'secret' variables.
     // should use values that are obtained from github.
     final static private String client_id    = "ea9c18f540323b0213d0";
@@ -102,7 +104,7 @@ public class Github implements OAuthProvider {
         UserTable userInfo = new UserTable();
 
         if (accessToken == null) {
         UserTable userInfo = new UserTable();
 
         if (accessToken == null) {
-            Log.w("accessToken is null!");
+            Log.warn("accessToken is null!");
             return null;
         }
 
             return null;
         }
 
@@ -118,7 +120,7 @@ public class Github implements OAuthProvider {
                     request, OAuth.HttpMethod.GET, OAuthResourceResponse.class);
 
             response = resourceResponse.getBody();
                     request, OAuth.HttpMethod.GET, OAuthResourceResponse.class);
 
             response = resourceResponse.getBody();
-            Log.d("response: " + response);
+            Log.debug("response: " + response);
 
         } catch (OAuthSystemException | OAuthProblemException e) {
             e.printStackTrace();
 
         } catch (OAuthSystemException | OAuthProblemException e) {
             e.printStackTrace();
@@ -132,7 +134,7 @@ public class Github implements OAuthProvider {
                 HashMap.class);
 
         if (parsedData == null) {
                 HashMap.class);
 
         if (parsedData == null) {
-            Log.d("parsedData is null!");
+            Log.debug("parsedData is null!");
             return null;
         }
 
             return null;
         }
 
index 72577c7..d2e1de6 100644 (file)
@@ -23,6 +23,8 @@ package org.iotivity.cloud.accountserver.oauth;
 
 import java.util.HashMap;
 
 
 import java.util.HashMap;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.apache.oltu.oauth2.client.OAuthClient;
 import org.apache.oltu.oauth2.client.URLConnectionClient;
 import org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest;
 import org.apache.oltu.oauth2.client.OAuthClient;
 import org.apache.oltu.oauth2.client.URLConnectionClient;
 import org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest;
@@ -39,7 +41,6 @@ import org.iotivity.cloud.accountserver.db.TokenTable;
 import org.iotivity.cloud.accountserver.db.UserTable;
 import org.iotivity.cloud.base.exception.ServerException.InternalServerErrorException;
 import org.iotivity.cloud.util.JSONUtil;
 import org.iotivity.cloud.accountserver.db.UserTable;
 import org.iotivity.cloud.base.exception.ServerException.InternalServerErrorException;
 import org.iotivity.cloud.util.JSONUtil;
-import org.iotivity.cloud.util.Log;;
 
 /**
  *
 
 /**
  *
@@ -49,6 +50,7 @@ import org.iotivity.cloud.util.Log;;
  */
 public class Google implements OAuthProvider {
 
  */
 public class Google implements OAuthProvider {
 
+    private final static Logger Log          = LoggerFactory.getLogger(Google.class);
     // do not use 'client_id' and 'secret' variables.
     // should use values that are obtained from github.
     final static private String client_id    = "447649044559-f9r5sl6op3kkk0312u384o4g6hhucje1.apps.googleusercontent.com";
     // do not use 'client_id' and 'secret' variables.
     // should use values that are obtained from github.
     final static private String client_id    = "447649044559-f9r5sl6op3kkk0312u384o4g6hhucje1.apps.googleusercontent.com";
@@ -63,7 +65,7 @@ public class Google implements OAuthProvider {
 
         if (authCode == null) {
 
 
         if (authCode == null) {
 
-            Log.w("authCode is null!");
+            Log.warn("authCode is null!");
             return tokenInfo;
         }
 
             return tokenInfo;
         }
 
@@ -84,7 +86,7 @@ public class Google implements OAuthProvider {
 
             oauthResponse = oauthClient.accessToken(request, cl);
 
 
             oauthResponse = oauthClient.accessToken(request, cl);
 
-            Log.d("OAuth response: " + oauthResponse.getBody());
+            Log.debug("OAuth response: " + oauthResponse.getBody());
 
             tokenInfo.setAccesstoken(oauthResponse.getAccessToken());
             tokenInfo.setRefreshtoken(oauthResponse.getRefreshToken());
 
             tokenInfo.setAccesstoken(oauthResponse.getAccessToken());
             tokenInfo.setRefreshtoken(oauthResponse.getRefreshToken());
@@ -107,7 +109,7 @@ public class Google implements OAuthProvider {
 
         if (refreshToken == null) {
 
 
         if (refreshToken == null) {
 
-            Log.w("refreshToken is null!");
+            Log.warn("refreshToken is null!");
             return tokenInfo;
         }
 
             return tokenInfo;
         }
 
@@ -127,7 +129,7 @@ public class Google implements OAuthProvider {
 
             oauthResponse = oauthClient.accessToken(request, cl);
 
 
             oauthResponse = oauthClient.accessToken(request, cl);
 
-            Log.d("OAuth response: " + oauthResponse.getBody());
+            Log.debug("OAuth response: " + oauthResponse.getBody());
 
             tokenInfo.setAccesstoken(oauthResponse.getAccessToken());
             // Google provides refreshToken in one time.
 
             tokenInfo.setAccesstoken(oauthResponse.getAccessToken());
             // Google provides refreshToken in one time.
@@ -150,7 +152,7 @@ public class Google implements OAuthProvider {
         UserTable userInfo = new UserTable();
 
         if (accessToken == null) {
         UserTable userInfo = new UserTable();
 
         if (accessToken == null) {
-            Log.w("accessToken is null!");
+            Log.warn("accessToken is null!");
             return userInfo;
         }
 
             return userInfo;
         }
 
@@ -168,7 +170,7 @@ public class Google implements OAuthProvider {
                     request, OAuth.HttpMethod.GET, OAuthResourceResponse.class);
 
             response = resourceResponse.getBody();
                     request, OAuth.HttpMethod.GET, OAuthResourceResponse.class);
 
             response = resourceResponse.getBody();
-            Log.d("response: " + response);
+            Log.debug("response: " + response);
 
         } catch (OAuthSystemException | OAuthProblemException e) {
             e.printStackTrace();
 
         } catch (OAuthSystemException | OAuthProblemException e) {
             e.printStackTrace();
@@ -183,7 +185,7 @@ public class Google implements OAuthProvider {
                 HashMap.class);
 
         if (parsedData == null) {
                 HashMap.class);
 
         if (parsedData == null) {
-            Log.d("parsedData is null!");
+            Log.debug("parsedData is null!");
             return userInfo;
         }
 
             return userInfo;
         }
 
index 52f3148..d5d390c 100644 (file)
@@ -26,13 +26,11 @@ import java.io.IOException;
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.net.URLClassLoader;
-import java.util.Set;
 
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.TokenTable;
 import org.iotivity.cloud.accountserver.db.UserTable;
 import org.iotivity.cloud.base.exception.ServerException.InternalServerErrorException;
 
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.TokenTable;
 import org.iotivity.cloud.accountserver.db.UserTable;
 import org.iotivity.cloud.base.exception.ServerException.InternalServerErrorException;
-import org.iotivity.cloud.util.Log;
 import org.reflections.Reflections;
 import org.reflections.scanners.SubTypesScanner;
 import org.reflections.util.ClasspathHelper;
 import org.reflections.Reflections;
 import org.reflections.scanners.SubTypesScanner;
 import org.reflections.util.ClasspathHelper;
index fd2da9d..dcd71a1 100644 (file)
@@ -38,6 +38,8 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.UUID;
 
 import java.util.List;
 import java.util.UUID;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.AccountDBManager;
 import org.iotivity.cloud.accountserver.db.TokenTable;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.AccountDBManager;
 import org.iotivity.cloud.accountserver.db.TokenTable;
@@ -51,7 +53,6 @@ import org.iotivity.cloud.base.exception.ServerException.BadRequestException;
 import org.iotivity.cloud.base.exception.ServerException.InternalServerErrorException;
 import org.iotivity.cloud.base.exception.ServerException.NotFoundException;
 import org.iotivity.cloud.base.exception.ServerException.UnAuthorizedException;
 import org.iotivity.cloud.base.exception.ServerException.InternalServerErrorException;
 import org.iotivity.cloud.base.exception.ServerException.NotFoundException;
 import org.iotivity.cloud.base.exception.ServerException.UnAuthorizedException;
-import org.iotivity.cloud.util.Log;
 
 /**
  *
 
 /**
  *
@@ -60,7 +61,7 @@ import org.iotivity.cloud.util.Log;
  *
  */
 public class AccountManager {
  *
  */
 public class AccountManager {
-
+    private final static Logger            Log                       = LoggerFactory.getLogger(AccountManager.class);
     private OAuthProviderFactory           mFactory                  = null;
     private TypeCastingManager<UserTable>  mUserTableCastingManager  = new TypeCastingManager<>();
     private TypeCastingManager<TokenTable> mTokenTableCastingManager = new TypeCastingManager<>();
     private OAuthProviderFactory           mFactory                  = null;
     private TypeCastingManager<UserTable>  mUserTableCastingManager  = new TypeCastingManager<>();
     private TypeCastingManager<TokenTable> mTokenTableCastingManager = new TypeCastingManager<>();
@@ -241,7 +242,7 @@ public class AccountManager {
     private String checkAuthProviderName(String authProviderName) {
         String libraryFileName = getValidFileName(Constants.OAUTH_LIBRARIES_PATH, authProviderName + ".jar");
         if (libraryFileName == null) {
     private String checkAuthProviderName(String authProviderName) {
         String libraryFileName = getValidFileName(Constants.OAUTH_LIBRARIES_PATH, authProviderName + ".jar");
         if (libraryFileName == null) {
-            Log.w("OAuth 3rd party library " + authProviderName + " does not exist.");
+            Log.warn("OAuth 3rd party library " + authProviderName + " does not exist.");
             return authProviderName;
         }
         return libraryFileName.substring(0, libraryFileName.length() - 4);
             return authProviderName;
         }
         return libraryFileName.substring(0, libraryFileName.length() - 4);
@@ -349,16 +350,16 @@ public class AccountManager {
     private TokenTable requestAccessToken(String authCode, Object options) {
         TokenTable tokenInfo = mFactory.requestAccessTokenInfo(authCode,
                 options);
     private TokenTable requestAccessToken(String authCode, Object options) {
         TokenTable tokenInfo = mFactory.requestAccessTokenInfo(authCode,
                 options);
-        Log.d("access token : " + tokenInfo.getAccesstoken());
-        Log.d("refresh token : " + tokenInfo.getRefreshtoken());
-        Log.d("expired time : " + tokenInfo.getExpiredtime());
+        Log.debug("access token : " + tokenInfo.getAccesstoken());
+        Log.debug("refresh token : " + tokenInfo.getRefreshtoken());
+        Log.debug("expired time : " + tokenInfo.getExpiredtime());
 
         return tokenInfo;
     }
 
     private UserTable requestUserInfo(String accessToken, Object options) {
         UserTable userInfo = mFactory.requestGetUserInfo(accessToken, options);
 
         return tokenInfo;
     }
 
     private UserTable requestUserInfo(String accessToken, Object options) {
         UserTable userInfo = mFactory.requestGetUserInfo(accessToken, options);
-        Log.d("user id  : " + userInfo.getUserid());
+        Log.debug("user id  : " + userInfo.getUserid());
 
         return userInfo;
     }
 
         return userInfo;
     }
@@ -366,7 +367,7 @@ public class AccountManager {
     private String generateUuid() {
         UUID uuid = UUID.randomUUID();
         String userUuid = uuid.toString();
     private String generateUuid() {
         UUID uuid = UUID.randomUUID();
         String userUuid = uuid.toString();
-        Log.d("generated uuid : " + userUuid);
+        Log.debug("generated uuid : " + userUuid);
         return userUuid;
     }
 
         return userUuid;
     }
 
@@ -415,10 +416,10 @@ public class AccountManager {
 
     private boolean checkRefreshTokenInDB(TokenTable tokenInfo, String token) {
         if (tokenInfo.getRefreshtoken() == null) {
 
     private boolean checkRefreshTokenInDB(TokenTable tokenInfo, String token) {
         if (tokenInfo.getRefreshtoken() == null) {
-            Log.w("Refreshtoken doesn't exist");
+            Log.warn("Refreshtoken doesn't exist");
             return false;
         } else if (!tokenInfo.getRefreshtoken().equals(token)) {
             return false;
         } else if (!tokenInfo.getRefreshtoken().equals(token)) {
-            Log.w("Refreshtoken is not correct");
+            Log.warn("Refreshtoken is not correct");
             return false;
         }
         return true;
             return false;
         }
         return true;
@@ -426,10 +427,10 @@ public class AccountManager {
 
     private boolean checkAccessTokenInDB(TokenTable tokenInfo, String token) {
         if (tokenInfo.getAccesstoken() == null) {
 
     private boolean checkAccessTokenInDB(TokenTable tokenInfo, String token) {
         if (tokenInfo.getAccesstoken() == null) {
-            Log.w("AccessToken doesn't exist");
+            Log.warn("AccessToken doesn't exist");
             return false;
         } else if (!tokenInfo.getAccesstoken().equals(token)) {
             return false;
         } else if (!tokenInfo.getAccesstoken().equals(token)) {
-            Log.w("AccessToken is not correct");
+            Log.warn("AccessToken is not correct");
             return false;
         }
         return true;
             return false;
         }
         return true;
@@ -443,7 +444,7 @@ public class AccountManager {
         long remainTime = getElaspedSeconds(issuedTime);
 
         if (remainTime > expiredTime) {
         long remainTime = getElaspedSeconds(issuedTime);
 
         if (remainTime > expiredTime) {
-            Log.w("access token is expired");
+            Log.warn("access token is expired");
             return false;
         }
         return true;
             return false;
         }
         return true;
@@ -463,7 +464,7 @@ public class AccountManager {
 
         long difference = currentTime.getTime() - issuedTimeDate.getTime();
         long elaspedSeconds = difference / 1000;
 
         long difference = currentTime.getTime() - issuedTimeDate.getTime();
         long elaspedSeconds = difference / 1000;
-        Log.d("accessToken elasped time: " + elaspedSeconds + "s");
+        Log.debug("accessToken elasped time: " + elaspedSeconds + "s");
 
         return elaspedSeconds;
     }
 
         return elaspedSeconds;
     }
@@ -494,9 +495,9 @@ public class AccountManager {
 
         TokenTable tokenInfo = mFactory.requestRefreshTokenInfo(refreshToken);
 
 
         TokenTable tokenInfo = mFactory.requestRefreshTokenInfo(refreshToken);
 
-        Log.d("access token : " + tokenInfo.getAccesstoken());
-        Log.d("refresh token : " + tokenInfo.getRefreshtoken());
-        Log.d("expired time : " + tokenInfo.getExpiredtime());
+        Log.debug("access token : " + tokenInfo.getAccesstoken());
+        Log.debug("refresh token : " + tokenInfo.getRefreshtoken());
+        Log.debug("expired time : " + tokenInfo.getExpiredtime());
 
         return tokenInfo;
     }
 
         return tokenInfo;
     }
@@ -516,7 +517,7 @@ public class AccountManager {
         }
 
         response.put(Constants.RESP_USER_LIST, ulist);
         }
 
         response.put(Constants.RESP_USER_LIST, ulist);
-        Log.d("User List " + response.toString());
+        Log.debug("User List " + response.toString());
 
         return response;
     }
 
         return response;
     }
index 5f67c93..53358fe 100644 (file)
@@ -25,6 +25,8 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 
 import java.util.HashMap;
 import java.util.List;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.resources.account.AccountManager.SearchOperation;
 import org.iotivity.cloud.base.device.Device;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.resources.account.AccountManager.SearchOperation;
 import org.iotivity.cloud.base.device.Device;
@@ -38,7 +40,6 @@ import org.iotivity.cloud.base.protocols.enums.ContentFormat;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.base.resource.Resource;
 import org.iotivity.cloud.util.Cbor;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.base.resource.Resource;
 import org.iotivity.cloud.util.Cbor;
-import org.iotivity.cloud.util.Log;
 
 /**
  *
 
 /**
  *
@@ -47,6 +48,7 @@ import org.iotivity.cloud.util.Log;
  *
  */
 public class AccountResource extends Resource {
  *
  */
 public class AccountResource extends Resource {
+    private final static Logger           Log        = LoggerFactory.getLogger(AccountResource.class);
 
     private Cbor<HashMap<String, Object>> mCbor      = new Cbor<>();
 
 
     private Cbor<HashMap<String, Object>> mCbor      = new Cbor<>();
 
@@ -110,7 +112,7 @@ public class AccountResource extends Resource {
             String authProvider = payloadData.get(Constants.REQ_AUTH_PROVIDER)
                     .toString();
 
             String authProvider = payloadData.get(Constants.REQ_AUTH_PROVIDER)
                     .toString();
 
-            Log.d("authCode: " + authCode);
+            Log.debug("authCode: " + authCode);
 
             Object options = payloadData.get(Constants.REQ_AUTH_OPTIONS);
 
 
             Object options = payloadData.get(Constants.REQ_AUTH_OPTIONS);
 
@@ -145,7 +147,7 @@ public class AccountResource extends Resource {
                     SearchOperation.OR));
         }
 
                     SearchOperation.OR));
         }
 
-        Log.d("Search criteria query : " + queryData);
+        Log.debug("Search criteria query : " + queryData);
 
         return MessageBuilder.createResponse(request, ResponseStatus.CONTENT,
                 ContentFormat.APPLICATION_CBOR,
 
         return MessageBuilder.createResponse(request, ResponseStatus.CONTENT,
                 ContentFormat.APPLICATION_CBOR,
index c302c83..9fff8e0 100644 (file)
@@ -6,6 +6,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.ListIterator;
 
 import java.util.List;
 import java.util.ListIterator;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.AccountDBManager;
 import org.iotivity.cloud.accountserver.db.AceTable;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.AccountDBManager;
 import org.iotivity.cloud.accountserver.db.AceTable;
@@ -25,6 +27,7 @@ import org.iotivity.cloud.base.exception.ServerException.InternalServerErrorExce
  */
 
 public class GroupAclManager {
  */
 
 public class GroupAclManager {
+    private final static Logger             Log              = LoggerFactory.getLogger(GroupAclManager.class);
     private static GroupAclManager          mGrAclManager    = new GroupAclManager();
     private TypeCastingManager<AceTable>    mTypeAceTable    = new TypeCastingManager<AceTable>();
     private TypeCastingManager<AceResource> mTypeAceResource = new TypeCastingManager<AceResource>();
     private static GroupAclManager          mGrAclManager    = new GroupAclManager();
     private TypeCastingManager<AceTable>    mTypeAceTable    = new TypeCastingManager<AceTable>();
     private TypeCastingManager<AceResource> mTypeAceResource = new TypeCastingManager<AceResource>();
index f675585..8ca3302 100644 (file)
@@ -6,6 +6,8 @@ import java.util.HashMap;
 import java.util.ListIterator;
 import java.util.UUID;
 
 import java.util.ListIterator;
 import java.util.UUID;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.AccountDBManager;
 import org.iotivity.cloud.accountserver.db.GroupTable;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.AccountDBManager;
 import org.iotivity.cloud.accountserver.db.GroupTable;
@@ -18,13 +20,13 @@ import org.iotivity.cloud.base.protocols.coap.CoapRequest;
 import org.iotivity.cloud.base.protocols.enums.ContentFormat;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.util.Cbor;
 import org.iotivity.cloud.base.protocols.enums.ContentFormat;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.util.Cbor;
-import org.iotivity.cloud.util.Log;
 
 /**
  * This class provides a set of APIs manage a group broker
  */
 public class GroupBrokerManager {
 
 
 /**
  * This class provides a set of APIs manage a group broker
  */
 public class GroupBrokerManager {
 
+    private final static Logger                         Log                = LoggerFactory.getLogger(GroupBrokerManager.class);
     private static GroupBrokerManager                   mGroupBrokerMgr    = new GroupBrokerManager();
     private TypeCastingManager<GroupTable>              mTypeGroup         = new TypeCastingManager<>();
     private HashMap<String, Object>                     mGroupResourceInfo = new HashMap<>();
     private static GroupBrokerManager                   mGroupBrokerMgr    = new GroupBrokerManager();
     private TypeCastingManager<GroupTable>              mTypeGroup         = new TypeCastingManager<>();
     private HashMap<String, Object>                     mGroupResourceInfo = new HashMap<>();
@@ -108,7 +110,7 @@ public class GroupBrokerManager {
             response.put(Constants.RESP_GROUPS, records);
         }
 
             response.put(Constants.RESP_GROUPS, records);
         }
 
-        Log.d("Group get response : " + response.toString());
+        Log.debug("Group get response : " + response.toString());
         return response;
     }
 
         return response;
     }
 
@@ -182,7 +184,7 @@ public class GroupBrokerManager {
             response.put(Constants.KEYFIELD_GROUP_PARENT, parent);
         }
 
             response.put(Constants.KEYFIELD_GROUP_PARENT, parent);
         }
 
-        Log.d("Group post response : " + response.toString());
+        Log.debug("Group post response : " + response.toString());
 
         return response;
     }
 
         return response;
     }
@@ -258,7 +260,7 @@ public class GroupBrokerManager {
                         && coapRequest.getTokenString().equals(
                                 ((CoapRequest) request).getTokenString())) {
                     iterator.remove();
                         && coapRequest.getTokenString().equals(
                                 ((CoapRequest) request).getTokenString())) {
                     iterator.remove();
-                    Log.d("subscriber removed, "
+                    Log.debug("subscriber removed, "
                             + ((CoapRequest) request).getTokenString());
                 }
             }
                             + ((CoapRequest) request).getTokenString());
                 }
             }
@@ -291,7 +293,7 @@ public class GroupBrokerManager {
                                     mCbor.encodingPayloadToCbor(
                                             makeGetResponse(uid))));
                 }
                                     mCbor.encodingPayloadToCbor(
                                             makeGetResponse(uid))));
                 }
-                Log.d("subscriber : " + uid
+                Log.debug("subscriber : " + uid
                         + " , subscriber internal Token list : "
                         + subscriberTokenList);
             }
                         + " , subscriber internal Token list : "
                         + subscriberTokenList);
             }
index 79aa494..16d8795 100644 (file)
@@ -26,13 +26,14 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 
 import java.util.HashMap;
 import java.util.List;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.AccountDBManager;
 import org.iotivity.cloud.accountserver.db.GroupTable;
 import org.iotivity.cloud.accountserver.util.TypeCastingManager;
 import org.iotivity.cloud.base.exception.ServerException.BadRequestException;
 import org.iotivity.cloud.base.exception.ServerException.PreconditionFailedException;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.AccountDBManager;
 import org.iotivity.cloud.accountserver.db.GroupTable;
 import org.iotivity.cloud.accountserver.util.TypeCastingManager;
 import org.iotivity.cloud.base.exception.ServerException.BadRequestException;
 import org.iotivity.cloud.base.exception.ServerException.PreconditionFailedException;
-import org.iotivity.cloud.util.Log;
 
 /**
  *
 
 /**
  *
@@ -41,6 +42,8 @@ import org.iotivity.cloud.util.Log;
  */
 
 public class GroupManager {
  */
 
 public class GroupManager {
+
+    private final static Logger            Log                 = LoggerFactory.getLogger(GroupManager.class);
     private static GroupManager            mGrManager          = new GroupManager();
     private TypeCastingManager<GroupTable> mTypeGroup          = new TypeCastingManager<GroupTable>();
     private GroupPolicyManager             mGroupPolicyManager = new GroupPolicyManager();
     private static GroupManager            mGrManager          = new GroupManager();
     private TypeCastingManager<GroupTable> mTypeGroup          = new TypeCastingManager<GroupTable>();
     private GroupPolicyManager             mGroupPolicyManager = new GroupPolicyManager();
@@ -420,7 +423,7 @@ public class GroupManager {
      */
     private <T> void addProperties(String gid, String property,
             ArrayList<T> values) {
      */
     private <T> void addProperties(String gid, String property,
             ArrayList<T> values) {
-        Log.d("added property name: " + property + ", values : " + values
+        Log.debug("added property name: " + property + ", values : " + values
                 + " , to group : " + gid);
         if (values == null || values.isEmpty()) {
             return;
                 + " , to group : " + gid);
         if (values == null || values.isEmpty()) {
             return;
@@ -450,7 +453,7 @@ public class GroupManager {
      */
     private <T> void deleteProperties(String gid, String property,
             ArrayList<T> values) {
      */
     private <T> void deleteProperties(String gid, String property,
             ArrayList<T> values) {
-        Log.d("deleted property name: " + property + ", values : " + values
+        Log.debug("deleted property name: " + property + ", values : " + values
                 + " , from group : " + gid);
         GroupTable groupTable = getGroupTable(gid);
         if (groupTable == null || values == null || values.isEmpty()) {
                 + " , from group : " + gid);
         GroupTable groupTable = getGroupTable(gid);
         if (groupTable == null || values == null || values.isEmpty()) {
@@ -486,7 +489,7 @@ public class GroupManager {
      *            value string
      */
     private void replaceProperties(String gid, String property, String value) {
      *            value string
      */
     private void replaceProperties(String gid, String property, String value) {
-        Log.d("replaced property name: " + property + ", value : " + value
+        Log.debug("replaced property name: " + property + ", value : " + value
                 + ", to group : " + gid);
         if (value == null || value.isEmpty()) {
             return;
                 + ", to group : " + gid);
         if (value == null || value.isEmpty()) {
             return;
index 3f06327..9aa8119 100644 (file)
@@ -28,6 +28,8 @@ import java.util.List;
 import java.util.ListIterator;
 import java.util.UUID;
 
 import java.util.ListIterator;
 import java.util.UUID;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.AccountDBManager;
 import org.iotivity.cloud.accountserver.db.AclTable;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.AccountDBManager;
 import org.iotivity.cloud.accountserver.db.AclTable;
@@ -41,10 +43,9 @@ import org.iotivity.cloud.base.protocols.MessageBuilder;
 import org.iotivity.cloud.base.protocols.enums.ContentFormat;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.util.Cbor;
 import org.iotivity.cloud.base.protocols.enums.ContentFormat;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.util.Cbor;
-import org.iotivity.cloud.util.Log;
 
 public class Acl {
 
 public class Acl {
-
+    private final static Logger           Log      = LoggerFactory.getLogger(Acl.class);
     private Cbor<HashMap<String, Object>> mCbor    = new Cbor<>();
     private String                        mAclid   = null;
     private String                        mOid     = null;
     private Cbor<HashMap<String, Object>> mCbor    = new Cbor<>();
     private String                        mAclid   = null;
     private String                        mOid     = null;
@@ -149,7 +150,7 @@ public class Acl {
 
     public List<HashMap<String, Object>> addACE(
             List<HashMap<String, Object>> aclist) {
 
     public List<HashMap<String, Object>> addACE(
             List<HashMap<String, Object>> aclist) {
-        Log.v("IN addACE");
+        Log.trace("IN addACE");
         HashMap<String, Object> hashmap = AccountDBManager.getInstance()
                 .selectRecord(Constants.ACL_TABLE, getCondition()).get(0);
         if (hashmap == null) {
         HashMap<String, Object> hashmap = AccountDBManager.getInstance()
                 .selectRecord(Constants.ACL_TABLE, getCondition()).get(0);
         if (hashmap == null) {
@@ -180,7 +181,7 @@ public class Acl {
         AccountDBManager.getInstance().updateRecord(Constants.ACL_TABLE,
                 hashmap);
         notifyToSubscriber(getResponsePayload(true));
         AccountDBManager.getInstance().updateRecord(Constants.ACL_TABLE,
                 hashmap);
         notifyToSubscriber(getResponsePayload(true));
-        Log.v("OUT addACE");
+        Log.trace("OUT addACE");
         return aclist;
     }
 
         return aclist;
     }
 
@@ -226,7 +227,7 @@ public class Acl {
     }
 
     public void updateACE(String aceid, HashMap<String, Object> ace) {
     }
 
     public void updateACE(String aceid, HashMap<String, Object> ace) {
-        Log.v("IN updateACE");
+        Log.trace("IN updateACE");
 
         HashMap<String, Object> hashmap = AccountDBManager.getInstance()
                 .selectRecord(Constants.ACL_TABLE, getCondition()).get(0);
 
         HashMap<String, Object> hashmap = AccountDBManager.getInstance()
                 .selectRecord(Constants.ACL_TABLE, getCondition()).get(0);
@@ -251,7 +252,7 @@ public class Acl {
         AccountDBManager.getInstance().updateRecord(Constants.ACL_TABLE,
                 hashmap);
         notifyToSubscriber(getResponsePayload(true));
         AccountDBManager.getInstance().updateRecord(Constants.ACL_TABLE,
                 hashmap);
         notifyToSubscriber(getResponsePayload(true));
-        Log.v("OUT updateACE");
+        Log.trace("OUT updateACE");
 
     }
 
 
     }
 
index 081315f..c5df3ce 100644 (file)
@@ -35,8 +35,6 @@ import org.iotivity.cloud.base.device.Device;
 import org.iotivity.cloud.base.exception.ServerException.BadRequestException;
 import org.iotivity.cloud.base.protocols.IRequest;
 
 import org.iotivity.cloud.base.exception.ServerException.BadRequestException;
 import org.iotivity.cloud.base.protocols.IRequest;
 
-import org.iotivity.cloud.util.Log;
-
 public class AclManager {
     public HashMap<String, Acl>          mAcls    = new HashMap<>();
     private TypeCastingManager<AclTable> mTypeAcl = new TypeCastingManager<AclTable>();
 public class AclManager {
     public HashMap<String, Acl>          mAcls    = new HashMap<>();
     private TypeCastingManager<AclTable> mTypeAcl = new TypeCastingManager<AclTable>();
index 4ba157a..c204970 100644 (file)
  */
 package org.iotivity.cloud.accountserver.resources.credprov.cert;
 
  */
 package org.iotivity.cloud.accountserver.resources.credprov.cert;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.bouncycastle.asn1.x500.X500Name;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.AccountDBManager;
 import org.iotivity.cloud.accountserver.x509.cert.Utility;
 import org.bouncycastle.asn1.x500.X500Name;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.AccountDBManager;
 import org.iotivity.cloud.accountserver.x509.cert.Utility;
-import org.iotivity.cloud.util.Log;
 
 import java.io.File;
 import java.io.FileInputStream;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -44,11 +45,12 @@ import static java.security.cert.CertificateFactory.getInstance;
  * This utility class is used for getting all properties from properties file.
  */
 public final class CertificateConstants {
  * This utility class is used for getting all properties from properties file.
  */
 public final class CertificateConstants {
+    private final static Logger     Log         = LoggerFactory.getLogger(CertificateConstants.class);
 
     /**
      * Properties object is used for loading pre-defined configurations: algorithm names and so on.
      */
 
     /**
      * Properties object is used for loading pre-defined configurations: algorithm names and so on.
      */
-    public static final Properties PROPERTIES = new Properties();
+    public static final Properties  PROPERTIES  = new Properties();
 
     /**
      * Load properties from specified properties file.
 
     /**
      * Load properties from specified properties file.
@@ -57,7 +59,7 @@ public final class CertificateConstants {
         try (FileInputStream inputStream = new FileInputStream(Constants.PROPERTIES_FILE_NAME)) {
             PROPERTIES.load(inputStream);
         } catch (IOException e) {
         try (FileInputStream inputStream = new FileInputStream(Constants.PROPERTIES_FILE_NAME)) {
             PROPERTIES.load(inputStream);
         } catch (IOException e) {
-            Log.e(e.getMessage());
+            Log.error(e.getMessage());
         }
     }
 
         }
     }
 
@@ -141,7 +143,7 @@ public final class CertificateConstants {
         try {
             CERTIFICATE_FACTORY = getInstance("X509");
         } catch (CertificateException e) {
         try {
             CERTIFICATE_FACTORY = getInstance("X509");
         } catch (CertificateException e) {
-            Log.e(e.getMessage());
+            Log.error(e.getMessage());
         }
     }
 
         }
     }
 
@@ -162,7 +164,7 @@ public final class CertificateConstants {
         try (FileOutputStream outputStream = new FileOutputStream(Constants.PROPERTIES_FILE_NAME)) {
             PROPERTIES.store(outputStream, "New Serial number");
         } catch (IOException e) {
         try (FileOutputStream outputStream = new FileOutputStream(Constants.PROPERTIES_FILE_NAME)) {
             PROPERTIES.store(outputStream, "New Serial number");
         } catch (IOException e) {
-            Log.e(e.getMessage());
+            Log.error(e.getMessage());
         }
     }
 
         }
     }
 
index 13bf1d5..9db800f 100644 (file)
@@ -21,6 +21,8 @@
  */
 package org.iotivity.cloud.accountserver.resources.credprov.cert;
 
  */
 package org.iotivity.cloud.accountserver.resources.credprov.cert;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.bouncycastle.asn1.ASN1Encodable;
 import org.bouncycastle.asn1.DERSequence;
 import org.bouncycastle.asn1.x509.Extension;
 import org.bouncycastle.asn1.ASN1Encodable;
 import org.bouncycastle.asn1.DERSequence;
 import org.bouncycastle.asn1.x509.Extension;
@@ -45,7 +47,6 @@ import org.iotivity.cloud.base.protocols.enums.ContentFormat;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.base.resource.Resource;
 import org.iotivity.cloud.util.Cbor;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.base.resource.Resource;
 import org.iotivity.cloud.util.Cbor;
-import org.iotivity.cloud.util.Log;
 
 import java.io.IOException;
 import java.security.GeneralSecurityException;
 
 import java.io.IOException;
 import java.security.GeneralSecurityException;
@@ -70,12 +71,13 @@ import static org.iotivity.cloud.accountserver.resources.credprov.cert.Certifica
  * personal certificate, issued by CA certificate and certificate chain.
  */
 public class CertificateResource extends Resource {
  * personal certificate, issued by CA certificate and certificate chain.
  */
 public class CertificateResource extends Resource {
+    private final static Logger                     Log         = LoggerFactory.getLogger(CertificateResource.class);
 
     /**
      * This constant object is used for parsing cbor payload to Map object and to
      * encoding map object to cbor format.
      */
 
     /**
      * This constant object is used for parsing cbor payload to Map object and to
      * encoding map object to cbor format.
      */
-    private static final Cbor<Map<String, Object>> MAP_CBOR = new Cbor<>();
+    private static final Cbor<Map<String, Object>>  MAP_CBOR    = new Cbor<>();
 
     /**
      * Inserts BouncyCastleProvider into 0 position in security provider list,
 
     /**
      * Inserts BouncyCastleProvider into 0 position in security provider list,
@@ -90,7 +92,7 @@ public class CertificateResource extends Resource {
                 CertificateStorage.load();
             }
         } catch (GeneralSecurityException | IOException | OperatorCreationException e) {
                 CertificateStorage.load();
             }
         } catch (GeneralSecurityException | IOException | OperatorCreationException e) {
-            Log.e(e.getMessage());
+            Log.error(e.getMessage());
         }
     }
 
         }
     }
 
@@ -179,7 +181,7 @@ public class CertificateResource extends Resource {
                                     try {
                                         CrlManager.CRL_MANAGER.revoke(certificateTable.getSerialNumber());
                                     } catch (CRLException | OperatorCreationException e) {
                                     try {
                                         CrlManager.CRL_MANAGER.revoke(certificateTable.getSerialNumber());
                                     } catch (CRLException | OperatorCreationException e) {
-                                        Log.e(e.getMessage() + e.getClass());
+                                        Log.error(e.getMessage() + e.getClass());
                                     }
                                     certificateManager.update(certificateTable, true);
                                 }
                                     }
                                     certificateManager.update(certificateTable, true);
                                 }
@@ -208,12 +210,12 @@ public class CertificateResource extends Resource {
                                                 ContentFormat.APPLICATION_CBOR,
                                                 MAP_CBOR.encodingPayloadToCbor(certificateManager.getPayLoad()));
                                     } catch (GeneralSecurityException | OperatorCreationException | CertIOException e) {
                                                 ContentFormat.APPLICATION_CBOR,
                                                 MAP_CBOR.encodingPayloadToCbor(certificateManager.getPayLoad()));
                                     } catch (GeneralSecurityException | OperatorCreationException | CertIOException e) {
-                                        Log.e(e.getMessage());
+                                        Log.error(e.getMessage());
                                     }
                                 }
                             }
                         } catch (IOException e) {
                                     }
                                 }
                             }
                         } catch (IOException e) {
-                            Log.e(e.getMessage());
+                            Log.error(e.getMessage());
                         }
                     }
                 }
                         }
                     }
                 }
index 9363549..3de3f7c 100644 (file)
  */
 package org.iotivity.cloud.accountserver.resources.credprov.cert;
 
  */
 package org.iotivity.cloud.accountserver.resources.credprov.cert;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.bouncycastle.asn1.x509.BasicConstraints;
 import org.bouncycastle.asn1.x509.Extension;
 import org.bouncycastle.jce.ECNamedCurveTable;
 import org.bouncycastle.operator.OperatorCreationException;
 import org.iotivity.cloud.accountserver.x509.cert.CertificateBuilder;
 import org.iotivity.cloud.accountserver.x509.cert.CertificateExtension;
 import org.bouncycastle.asn1.x509.BasicConstraints;
 import org.bouncycastle.asn1.x509.Extension;
 import org.bouncycastle.jce.ECNamedCurveTable;
 import org.bouncycastle.operator.OperatorCreationException;
 import org.iotivity.cloud.accountserver.x509.cert.CertificateBuilder;
 import org.iotivity.cloud.accountserver.x509.cert.CertificateExtension;
-import org.iotivity.cloud.util.Log;
 
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -46,6 +47,7 @@ import static org.iotivity.cloud.accountserver.resources.credprov.cert.Certifica
  * Also it generates CA certificate and puts it to keystore.
  */
 public final class CertificateStorage {
  * Also it generates CA certificate and puts it to keystore.
  */
 public final class CertificateStorage {
+    private final static Logger Log     = LoggerFactory.getLogger(CertificateStorage.class);
 
     /**
      * This attribute is used to get password to kestore, that stores CA certificate info.
 
     /**
      * This attribute is used to get password to kestore, that stores CA certificate info.
@@ -97,7 +99,7 @@ public final class CertificateStorage {
         try (InputStream inputStream = new FileInputStream(KEYSTORE_FILE)) {
             keyStore.load(inputStream, PASSWORD.toCharArray());
         } catch (IOException ioException) {
         try (InputStream inputStream = new FileInputStream(KEYSTORE_FILE)) {
             keyStore.load(inputStream, PASSWORD.toCharArray());
         } catch (IOException ioException) {
-            Log.e(ioException.getMessage());
+            Log.error(ioException.getMessage());
         }
         ROOT_PRIVATE_KEY = (PrivateKey) keyStore.getKey(CA_ALIAS, PASSWORD.toCharArray());
         ROOT_CERTIFICATE = (X509Certificate) keyStore.getCertificate(CA_ALIAS);
         }
         ROOT_PRIVATE_KEY = (PrivateKey) keyStore.getKey(CA_ALIAS, PASSWORD.toCharArray());
         ROOT_CERTIFICATE = (X509Certificate) keyStore.getCertificate(CA_ALIAS);
@@ -132,7 +134,7 @@ public final class CertificateStorage {
         try (FileOutputStream out = new FileOutputStream(KEYSTORE_FILE)) {
             keyStore.store(out, PASSWORD.toCharArray());
         } catch (IOException ioException) {
         try (FileOutputStream out = new FileOutputStream(KEYSTORE_FILE)) {
             keyStore.store(out, PASSWORD.toCharArray());
         } catch (IOException ioException) {
-            Log.e(ioException.getMessage());
+            Log.error(ioException.getMessage());
         }
     }
 }
         }
     }
 }
index 32b6ce9..27a9fcb 100644 (file)
@@ -40,24 +40,26 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
 import java.util.HashMap;
 import java.util.Map;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.bouncycastle.operator.OperatorCreationException;
 import org.bson.types.Binary;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.CRLTable;
 import org.iotivity.cloud.accountserver.util.TypeCastingManager;
 import org.iotivity.cloud.base.exception.ServerException;
 import org.bouncycastle.operator.OperatorCreationException;
 import org.bson.types.Binary;
 import org.iotivity.cloud.accountserver.Constants;
 import org.iotivity.cloud.accountserver.db.CRLTable;
 import org.iotivity.cloud.accountserver.util.TypeCastingManager;
 import org.iotivity.cloud.base.exception.ServerException;
-import org.iotivity.cloud.util.Log;
 
 /**
  * Class is used to manage CRLs. It helps to create, update CRLS, revoke
  * certificates.
  */
 public final class CrlManager {
 
 /**
  * Class is used to manage CRLs. It helps to create, update CRLS, revoke
  * certificates.
  */
 public final class CrlManager {
+    private final static Logger                 Log             = LoggerFactory.getLogger(CrlManager.class);
 
     /**
      * Casting manager for working with CRLTable in mongo db
      */
 
     /**
      * Casting manager for working with CRLTable in mongo db
      */
-    private static TypeCastingManager<CRLTable> castingManager = new TypeCastingManager<>();
+    private static TypeCastingManager<CRLTable> castingManager  = new TypeCastingManager<>();
 
     /**
      * X509 CRL presentation.
 
     /**
      * X509 CRL presentation.
@@ -85,7 +87,7 @@ public final class CrlManager {
                             new CRLTable(thisUpdate, new Binary(data))));
             setX509CRL(data);
         } catch (CRLException | IOException | OperatorCreationException e) {
                             new CRLTable(thisUpdate, new Binary(data))));
             setX509CRL(data);
         } catch (CRLException | IOException | OperatorCreationException e) {
-            Log.e(e.getMessage());
+            Log.error(e.getMessage());
         }
     }
 
         }
     }
 
@@ -141,7 +143,7 @@ public final class CrlManager {
                         .parse(lastUpdate).before(x509CRL.getThisUpdate());
             }
         } catch (ParseException e) {
                         .parse(lastUpdate).before(x509CRL.getThisUpdate());
             }
         } catch (ParseException e) {
-            Log.e(e.getMessage());
+            Log.error(e.getMessage());
         }
         return checkCondition;
     }
         }
         return checkCondition;
     }
index fa75701..652c7af 100644 (file)
@@ -34,6 +34,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import java.util.List;
 import java.util.Map;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.bouncycastle.operator.OperatorCreationException;
 import org.bouncycastle.util.encoders.Base64;
 import org.bouncycastle.util.encoders.DecoderException;
 import org.bouncycastle.operator.OperatorCreationException;
 import org.bouncycastle.util.encoders.Base64;
 import org.bouncycastle.util.encoders.DecoderException;
@@ -47,17 +49,17 @@ import org.iotivity.cloud.base.protocols.enums.ContentFormat;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.base.resource.Resource;
 import org.iotivity.cloud.util.Cbor;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.base.resource.Resource;
 import org.iotivity.cloud.util.Cbor;
-import org.iotivity.cloud.util.Log;
 
 /**
  * Class is used working with POST and GET requests and handles CRL requests.
  */
 public class CrlResource extends Resource {
 
 /**
  * Class is used working with POST and GET requests and handles CRL requests.
  */
 public class CrlResource extends Resource {
+    private final static Logger                     Log         = LoggerFactory.getLogger(CrlResource.class);
 
     /**
      * CBOR container with help of map presentation.
      */
 
     /**
      * CBOR container with help of map presentation.
      */
-    private static final Cbor<Map<String, Object>> MAP_CBOR = new Cbor<>();
+    private static final Cbor<Map<String, Object>>  MAP_CBOR    = new Cbor<>();
 
     /**
      * Creates resource for handling CRL requests(GET and POST)
 
     /**
      * Creates resource for handling CRL requests(GET and POST)
@@ -113,7 +115,7 @@ public class CrlResource extends Resource {
                                 MAP_CBOR.encodingPayloadToCbor(payload));
                     }
                 } catch (CRLException e) {
                                 MAP_CBOR.encodingPayloadToCbor(payload));
                     }
                 } catch (CRLException e) {
-                    Log.e(e.getMessage());
+                    Log.error(e.getMessage());
                 }
             }
         }
                 }
             }
         }
@@ -172,13 +174,13 @@ public class CrlResource extends Resource {
                                     response = MessageBuilder.createResponse(
                                             request, ResponseStatus.CHANGED);
                                 } catch (DecoderException e) {
                                     response = MessageBuilder.createResponse(
                                             request, ResponseStatus.CHANGED);
                                 } catch (DecoderException e) {
-                                    Log.e(e.getMessage() + e.getClass());
+                                    Log.error(e.getMessage() + e.getClass());
                                 }
                             }
                         }
                     } catch (CRLException | IOException
                             | OperatorCreationException | ParseException e) {
                                 }
                             }
                         }
                     } catch (CRLException | IOException
                             | OperatorCreationException | ParseException e) {
-                        Log.e(e.getMessage() + e.getClass());
+                        Log.error(e.getMessage() + e.getClass());
                     }
                 }
             }
                     }
                 }
             }
index 71fb1a0..6ac2003 100644 (file)
@@ -21,6 +21,8 @@
  */
 package org.iotivity.cloud.accountserver.x509.cert;
 
  */
 package org.iotivity.cloud.accountserver.x509.cert;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.bouncycastle.asn1.x500.AttributeTypeAndValue;
 import org.bouncycastle.asn1.x500.X500Name;
 import org.bouncycastle.openssl.PEMException;
 import org.bouncycastle.asn1.x500.AttributeTypeAndValue;
 import org.bouncycastle.asn1.x500.X500Name;
 import org.bouncycastle.openssl.PEMException;
@@ -29,7 +31,6 @@ import org.bouncycastle.operator.OperatorCreationException;
 import org.bouncycastle.operator.jcajce.JcaContentVerifierProviderBuilder;
 import org.bouncycastle.pkcs.PKCS10CertificationRequest;
 import org.bouncycastle.pkcs.PKCSException;
 import org.bouncycastle.operator.jcajce.JcaContentVerifierProviderBuilder;
 import org.bouncycastle.pkcs.PKCS10CertificationRequest;
 import org.bouncycastle.pkcs.PKCSException;
-import org.iotivity.cloud.util.Log;
 
 import java.io.IOException;
 import java.security.PublicKey;
 
 import java.io.IOException;
 import java.security.PublicKey;
@@ -41,6 +42,7 @@ import static org.iotivity.cloud.accountserver.resources.credprov.cert.Certifica
  * Class is used for parsing CSR requests.
  */
 public class CSRParser {
  * Class is used for parsing CSR requests.
  */
 public class CSRParser {
+    private final static Logger Log = LoggerFactory.getLogger(CSRParser.class);
 
     /**
      * PKCS10CertificationRequest attribute.
 
     /**
      * PKCS10CertificationRequest attribute.
@@ -71,7 +73,7 @@ public class CSRParser {
             publicKey = new JcaPEMKeyConverter().setProvider(SECURITY_PROVIDER).
                     getPublicKey(mCsr.getSubjectPublicKeyInfo());
         } catch (PEMException e) {
             publicKey = new JcaPEMKeyConverter().setProvider(SECURITY_PROVIDER).
                     getPublicKey(mCsr.getSubjectPublicKeyInfo());
         } catch (PEMException e) {
-            Log.e(e.getMessage());
+            Log.error(e.getMessage());
         }
         return publicKey;
     }
         }
         return publicKey;
     }
@@ -87,7 +89,7 @@ public class CSRParser {
             condition = mCsr.isSignatureValid(new JcaContentVerifierProviderBuilder()
                     .setProvider(SECURITY_PROVIDER).build(mCsr.getSubjectPublicKeyInfo()));
         } catch (OperatorCreationException | PKCSException e) {
             condition = mCsr.isSignatureValid(new JcaContentVerifierProviderBuilder()
                     .setProvider(SECURITY_PROVIDER).build(mCsr.getSubjectPublicKeyInfo()));
         } catch (OperatorCreationException | PKCSException e) {
-            Log.e(e.getMessage());
+            Log.error(e.getMessage());
         }
         return condition;
     }
         }
         return condition;
     }
diff --git a/cloud/account/src/main/resources/logback.xml b/cloud/account/src/main/resources/logback.xml
new file mode 100644 (file)
index 0000000..1ff4a85
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!-- To log coap message payload, include variable %X{coappayload} into pattern -->
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} | %-5level | %class{0}.%method:%L | %msg%n</pattern>
+        </encoder>
+    </appender>
+    <root level="trace">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
\ No newline at end of file
index bf66e30..71d5bf9 100644 (file)
@@ -14,7 +14,6 @@ import org.iotivity.cloud.accountserver.db.GroupTable;
 import org.iotivity.cloud.accountserver.db.MongoDB;
 import org.iotivity.cloud.accountserver.resources.acl.id.AclResource;
 import org.iotivity.cloud.accountserver.util.TypeCastingManager;
 import org.iotivity.cloud.accountserver.db.MongoDB;
 import org.iotivity.cloud.accountserver.resources.acl.id.AclResource;
 import org.iotivity.cloud.accountserver.util.TypeCastingManager;
-import org.iotivity.cloud.util.Log;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -94,7 +93,7 @@ public class GroupAclManagerTest {
 
     @Test
     public void testAddAceByResourcesOnlyOwner() {
 
     @Test
     public void testAddAceByResourcesOnlyOwner() {
-        Log.v("--------------testAddAceByResourcesOnlyOwner------------");
+        System.out.println("--------------testAddAceByResourcesOnlyOwner------------");
 
         // initialize group info --
         ArrayList<String> members = new ArrayList<>();
 
         // initialize group info --
         ArrayList<String> members = new ArrayList<>();
@@ -120,7 +119,7 @@ public class GroupAclManagerTest {
 
     @Test
     public void testAddAceByResources() {
 
     @Test
     public void testAddAceByResources() {
-        Log.v("--------------testAddAceByResoruces------------");
+        System.out.println("--------------testAddAceByResoruces------------");
 
         // initialize group info --
         ArrayList<String> members = new ArrayList<>();
 
         // initialize group info --
         ArrayList<String> members = new ArrayList<>();
@@ -172,7 +171,7 @@ public class GroupAclManagerTest {
 
     @Test
     public void testAddAceByResourcesNoMembers() {
 
     @Test
     public void testAddAceByResourcesNoMembers() {
-        Log.v("--------------testAddAceByResorucesNoMembers------------");
+        System.out.println("--------------testAddAceByResorucesNoMembers------------");
         setGroupInfo(mGid1, new HashMap<>());
 
         ArrayList<HashMap<String, Object>> resources = new ArrayList<>();
         setGroupInfo(mGid1, new HashMap<>());
 
         ArrayList<HashMap<String, Object>> resources = new ArrayList<>();
@@ -190,7 +189,7 @@ public class GroupAclManagerTest {
 
     @Test
     public void testAddAceByDevices() {
 
     @Test
     public void testAddAceByDevices() {
-        Log.v("--------------testAddAceByDevices------------");
+        System.out.println("--------------testAddAceByDevices------------");
 
         // initialize group info --
         ArrayList<String> members = new ArrayList<>();
 
         // initialize group info --
         ArrayList<String> members = new ArrayList<>();
@@ -227,7 +226,7 @@ public class GroupAclManagerTest {
 
     @Test
     public void testAddAceByDevicesOnlyOwner() {
 
     @Test
     public void testAddAceByDevicesOnlyOwner() {
-        Log.v("--------------testAddAceByDevicesOnlyOwner------------");
+        System.out.println("--------------testAddAceByDevicesOnlyOwner------------");
 
         // initialize group info --
         ArrayList<String> members = new ArrayList<>();
 
         // initialize group info --
         ArrayList<String> members = new ArrayList<>();
@@ -253,7 +252,7 @@ public class GroupAclManagerTest {
 
     @Test
     public void testAddAceByDevicesNoMembers() {
 
     @Test
     public void testAddAceByDevicesNoMembers() {
-        Log.v("--------------testAddAceByDevicesNoMembers------------");
+        System.out.println("--------------testAddAceByDevicesNoMembers------------");
         setGroupInfo(mGid1, new HashMap<>());
 
         ArrayList<String> devices = new ArrayList<>();
         setGroupInfo(mGid1, new HashMap<>());
 
         ArrayList<String> devices = new ArrayList<>();
@@ -270,7 +269,7 @@ public class GroupAclManagerTest {
 
     @Test
     public void testAddAceByMembersWithDevice() {
 
     @Test
     public void testAddAceByMembersWithDevice() {
-        Log.v("--------------testAddAceByMembersWithDevice------------");
+        System.out.println("--------------testAddAceByMembersWithDevice------------");
 
         // initialize group info --
         ArrayList<String> devices = new ArrayList<>();
 
         // initialize group info --
         ArrayList<String> devices = new ArrayList<>();
@@ -314,7 +313,7 @@ public class GroupAclManagerTest {
 
     @Test
     public void testAddAceByMembersWithDeviceAndResource() {
 
     @Test
     public void testAddAceByMembersWithDeviceAndResource() {
-        Log.v("--------------testAddAceByMembersWithDeviceAndResource------------");
+        System.out.println("--------------testAddAceByMembersWithDeviceAndResource------------");
 
         // initialize group info --
         ArrayList<String> devices = new ArrayList<>();
 
         // initialize group info --
         ArrayList<String> devices = new ArrayList<>();
@@ -401,7 +400,7 @@ public class GroupAclManagerTest {
 
     @Test
     public void testAddAceByMembersNoDevice() {
 
     @Test
     public void testAddAceByMembersNoDevice() {
-        Log.v("--------------testAddAceByMembersNoDevice------------");
+        System.out.println("--------------testAddAceByMembersNoDevice------------");
         setGroupInfo(mGid1, new HashMap<>());
 
         ArrayList<String> members = new ArrayList<>();
         setGroupInfo(mGid1, new HashMap<>());
 
         ArrayList<String> members = new ArrayList<>();
@@ -418,7 +417,7 @@ public class GroupAclManagerTest {
 
     @Test
     public void testAddAceByMembersOwnerDevice() {
 
     @Test
     public void testAddAceByMembersOwnerDevice() {
-        Log.v("--------------testAddAceByMembersOwnerDevice------------");
+        System.out.println("--------------testAddAceByMembersOwnerDevice------------");
 
         // initialize group info --
         ArrayList<String> devices = new ArrayList<>();
 
         // initialize group info --
         ArrayList<String> devices = new ArrayList<>();
@@ -444,7 +443,7 @@ public class GroupAclManagerTest {
 
     @Test
     public void testRemoveAceByGroup() {
 
     @Test
     public void testRemoveAceByGroup() {
-        Log.v("--------------testRemoveAceByGroup------------");
+        System.out.println("--------------testRemoveAceByGroup------------");
 
         // initialize group info --
         ArrayList<String> members = new ArrayList<>();
 
         // initialize group info --
         ArrayList<String> members = new ArrayList<>();
@@ -513,7 +512,7 @@ public class GroupAclManagerTest {
 
     @Test
     public void testRemoveAceByMembers() {
 
     @Test
     public void testRemoveAceByMembers() {
-        Log.v("--------------testRemoveAceByMembers------------");
+        System.out.println("--------------testRemoveAceByMembers------------");
 
         // initialize group info --
         ArrayList<String> devices = new ArrayList<>();
 
         // initialize group info --
         ArrayList<String> devices = new ArrayList<>();
@@ -573,7 +572,7 @@ public class GroupAclManagerTest {
 
     @Test
     public void testRemoveAceByDevices() {
 
     @Test
     public void testRemoveAceByDevices() {
-        Log.v("--------------testRemoveAceByDevices------------");
+        System.out.println("--------------testRemoveAceByDevices------------");
 
         // initialize group info --
         ArrayList<String> devices = new ArrayList<>();
 
         // initialize group info --
         ArrayList<String> devices = new ArrayList<>();
@@ -653,7 +652,7 @@ public class GroupAclManagerTest {
 
     @Test
     public void testRemoveAceByResourcesDeleteAce() {
 
     @Test
     public void testRemoveAceByResourcesDeleteAce() {
-        Log.v("--------------testRemoveAceByResourcesDeleteAce------------");
+        System.out.println("--------------testRemoveAceByResourcesDeleteAce------------");
 
         // initialize group info --
         ArrayList<String> devices = new ArrayList<>();
 
         // initialize group info --
         ArrayList<String> devices = new ArrayList<>();
@@ -774,11 +773,11 @@ public class GroupAclManagerTest {
 
     private boolean checkAclTable(String di, String aceid, String subjectUuid,
             List<HashMap<String, Object>> resource) {
 
     private boolean checkAclTable(String di, String aceid, String subjectUuid,
             List<HashMap<String, Object>> resource) {
-        Log.v("--------------checkAclTable : " + di + " ------------");
+        System.out.println("--------------checkAclTable : " + di + " ------------");
         HashMap<String, Object> getAclist = AclResource.getInstance()
                 .getAclACE((String) AclResource.getInstance().getAclid(di)
                         .get(Constants.KEYFIELD_ACLID), aceid);
         HashMap<String, Object> getAclist = AclResource.getInstance()
                 .getAclACE((String) AclResource.getInstance().getAclid(di)
                         .get(Constants.KEYFIELD_ACLID), aceid);
-        Log.v("check result : " + getAclist);
+        System.out.println("check result : " + getAclist);
         if (getAclist.isEmpty()) {
             return false;
         }
         if (getAclist.isEmpty()) {
             return false;
         }
@@ -812,10 +811,10 @@ public class GroupAclManagerTest {
 
     private boolean checkAceTable(HashMap<String, Object> condition,
             HashMap<String, Object> key) {
 
     private boolean checkAceTable(HashMap<String, Object> condition,
             HashMap<String, Object> key) {
-        Log.v("--------------checkAceTable : " + condition.toString()
+        System.out.println("--------------checkAceTable : " + condition.toString()
                 + " ------------");
         HashMap<String, Object> getAce = getAceTable(condition).get(0);
                 + " ------------");
         HashMap<String, Object> getAce = getAceTable(condition).get(0);
-        Log.v("check result : " + getAce);
+        System.out.println("check result : " + getAce);
         if (getAce.isEmpty()) {
             return false;
         }
         if (getAce.isEmpty()) {
             return false;
         }
index 158b637..0297ca4 100644 (file)
@@ -24,6 +24,8 @@ package org.iotivity.cloud.ciserver;
 import java.net.InetSocketAddress;
 import java.util.Scanner;
 
 import java.net.InetSocketAddress;
 import java.util.Scanner;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.connector.ConnectorPool;
 import org.iotivity.cloud.base.server.CoapServer;
 import org.iotivity.cloud.base.server.HttpServer;
 import org.iotivity.cloud.base.connector.ConnectorPool;
 import org.iotivity.cloud.base.server.CoapServer;
 import org.iotivity.cloud.base.server.HttpServer;
@@ -43,34 +45,30 @@ import org.iotivity.cloud.ciserver.resources.proxy.rd.DevicePresence;
 import org.iotivity.cloud.ciserver.resources.proxy.rd.ResourceDirectory;
 import org.iotivity.cloud.ciserver.resources.proxy.rd.ResourceFind;
 import org.iotivity.cloud.ciserver.resources.proxy.rd.ResourcePresence;
 import org.iotivity.cloud.ciserver.resources.proxy.rd.ResourceDirectory;
 import org.iotivity.cloud.ciserver.resources.proxy.rd.ResourceFind;
 import org.iotivity.cloud.ciserver.resources.proxy.rd.ResourcePresence;
-import org.iotivity.cloud.util.Log;
 
 public class CloudInterfaceServer {
 
 public class CloudInterfaceServer {
-
-    private static int[]   deviceKeepAliveMinutes = new int[] { 1, 2, 4, 8 };
-    private static int     coapServerPort;
-    private static boolean tlsMode;
-    private static boolean keepAlive = false;
-    private static boolean hcProxyMode;
-    private static int     hcProxyPort;
-    private static boolean websocketMode;
-    private static int     websocketPort;
-    private static String  resourceDirectoryAddress;
-    private static int     resourceDirectoryPort;
-    private static String  accountServerAddress;
-    private static int     accountServerPort;
-    private static String  messageQueueAddress;
-    private static int     messageQueuePort;
-    private static String  webLogHost;
+    private final static Logger Log = LoggerFactory.getLogger(CloudInterfaceServer.class);
+    private static int[]        deviceKeepAliveMinutes = new int[] { 1, 2, 4, 8 };
+    private static int          coapServerPort;
+    private static boolean      tlsMode;
+    private static boolean      keepAlive = false;
+    private static boolean      hcProxyMode;
+    private static int          hcProxyPort;
+    private static boolean      websocketMode;
+    private static int          websocketPort;
+    private static String       resourceDirectoryAddress;
+    private static int          resourceDirectoryPort;
+    private static String       accountServerAddress;
+    private static int          accountServerPort;
+    private static String       messageQueueAddress;
+    private static int          messageQueuePort;
 
     public static void main(String[] args) throws Exception {
 
     public static void main(String[] args) throws Exception {
-        System.out.println("-----CI SERVER-------");
-        Log.Init();
+        Log.info("Starting Cloud Interface Server");
 
         if (!parseConfiguration(args)) {
 
         if (!parseConfiguration(args)) {
-            Log.e("\nCoAP-server <Port> RD-server <Address> <Port> Account-server <Address> <Port> MQ-broker <Address> <Port> HC-proxy [HTTP-port] "
-                    + "Websocket-server <Port> and TLS-mode <0|1> are required. WebSocketLog-Server <Addres> <Port> "
-                    + "and KeepAlive for cloud components <0|1> are optional.\n"
+            Log.error("\nCoAP-server <Port> RD-server <Address> <Port> Account-server <Address> <Port> MQ-broker <Address> <Port> HC-proxy [HTTP-port] "
+                    + "Websocket-server <Port> and TLS-mode <0|1> are required.\n"
                     + "ex) " + Constants.DEFAULT_COAP_PORT
                     + " 127.0.0.1 " + Constants.DEFAULT_RESOURCE_DIRECTORY_PORT
                     + " 127.0.0.1 " + Constants.DEFAULT_ACCOUNT_SERVER_PORT
                     + "ex) " + Constants.DEFAULT_COAP_PORT
                     + " 127.0.0.1 " + Constants.DEFAULT_RESOURCE_DIRECTORY_PORT
                     + " 127.0.0.1 " + Constants.DEFAULT_ACCOUNT_SERVER_PORT
@@ -79,9 +77,6 @@ public class CloudInterfaceServer {
                     + " " + Constants.DEFAULT_WEBSOCKET_PORT + " 0\n");
             return;
         }
                     + " " + Constants.DEFAULT_WEBSOCKET_PORT + " 0\n");
             return;
         }
-        if (webLogHost != null)
-            Log.InitWebLog(webLogHost,
-                    CloudInterfaceServer.class.getSimpleName().toString());
 
         ConnectorPool.requestConnection("rd",
                 new InetSocketAddress(resourceDirectoryAddress, resourceDirectoryPort),
 
         ConnectorPool.requestConnection("rd",
                 new InetSocketAddress(resourceDirectoryAddress, resourceDirectoryPort),
@@ -173,7 +168,7 @@ public class CloudInterfaceServer {
 
     private static boolean parseConfiguration(String[] args) {
         // configuration provided by arguments
 
     private static boolean parseConfiguration(String[] args) {
         // configuration provided by arguments
-        if (args.length == 10 || args.length == 13) {
+        if (args.length == 10) {
             coapServerPort = Integer.parseInt(args[0]);
             resourceDirectoryAddress = args[1];
             resourceDirectoryPort = Integer.parseInt(args[2]);
             coapServerPort = Integer.parseInt(args[0]);
             resourceDirectoryAddress = args[1];
             resourceDirectoryPort = Integer.parseInt(args[2]);
@@ -186,10 +181,6 @@ public class CloudInterfaceServer {
             websocketPort = Integer.parseInt(args[8]);
             websocketMode = websocketPort != 0;
             tlsMode = Integer.parseInt(args[9]) == 1;
             websocketPort = Integer.parseInt(args[8]);
             websocketMode = websocketPort != 0;
             tlsMode = Integer.parseInt(args[9]) == 1;
-            if (args.length == 13) {
-                webLogHost = args[10] + ":" + args[11];
-                keepAlive = Integer.parseInt(args[12]) == 1;
-            }
 
             return true;
         }
 
             return true;
         }
index 4bbde23..b59331a 100644 (file)
@@ -25,6 +25,8 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 
 import java.util.Iterator;
 import java.util.List;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.OICConstants;
 import org.iotivity.cloud.base.ServerSystem;
 import org.iotivity.cloud.base.connector.ConnectorPool;
 import org.iotivity.cloud.base.OICConstants;
 import org.iotivity.cloud.base.ServerSystem;
 import org.iotivity.cloud.base.connector.ConnectorPool;
@@ -51,7 +53,6 @@ import org.iotivity.cloud.base.server.Server;
 import org.iotivity.cloud.base.server.WebSocketServer;
 import org.iotivity.cloud.util.Bytes;
 import org.iotivity.cloud.util.Cbor;
 import org.iotivity.cloud.base.server.WebSocketServer;
 import org.iotivity.cloud.util.Bytes;
 import org.iotivity.cloud.util.Cbor;
-import org.iotivity.cloud.util.Log;
 
 import io.netty.channel.ChannelDuplexHandler;
 import io.netty.channel.ChannelHandler.Sharable;
 
 import io.netty.channel.ChannelDuplexHandler;
 import io.netty.channel.ChannelHandler.Sharable;
@@ -66,7 +67,7 @@ import io.netty.channel.ChannelPromise;
  */
 
 public class DeviceServerSystem extends ServerSystem {
  */
 
 public class DeviceServerSystem extends ServerSystem {
-
+    private final static Logger                           Log     = LoggerFactory.getLogger(DeviceServerSystem.class);
     private Cbor<HashMap<String, Object>>                 mCbor   = new Cbor<HashMap<String, Object>>();
     private HashMap<ChannelHandlerContext, CoapSignaling> mCsmMap = new HashMap<>();
 
     private Cbor<HashMap<String, Object>>                 mCbor   = new Cbor<HashMap<String, Object>>();
     private HashMap<ChannelHandlerContext, CoapSignaling> mCsmMap = new HashMap<>();
 
@@ -194,7 +195,7 @@ public class DeviceServerSystem extends ServerSystem {
                         }
                     }
                 } catch (Throwable t) {
                         }
                     }
                 } catch (Throwable t) {
-                    Log.f(ctx.channel(), t);
+                    Log.error("[{}] channel error", ctx.channel().id().asLongText().substring(26), t);
                     ResponseStatus responseStatus = t instanceof ServerException
                             ? ((ServerException) t).getErrorResponse()
                             : ResponseStatus.INTERNAL_SERVER_ERROR;
                     ResponseStatus responseStatus = t instanceof ServerException
                             ? ((ServerException) t).getErrorResponse()
                             : ResponseStatus.INTERNAL_SERVER_ERROR;
@@ -373,7 +374,7 @@ public class DeviceServerSystem extends ServerSystem {
                 ctx.writeAndFlush(msg);
 
             } catch (Throwable t) {
                 ctx.writeAndFlush(msg);
 
             } catch (Throwable t) {
-                Log.f(ctx.channel(), t);
+                Log.error("[{}] channel error", ctx.channel().id().asLongText().substring(26), t);
                 ctx.writeAndFlush(msg);
                 ctx.close();
             }
                 ctx.writeAndFlush(msg);
                 ctx.close();
             }
@@ -452,7 +453,7 @@ public class DeviceServerSystem extends ServerSystem {
                         : ResponseStatus.UNAUTHORIZED;
                 ctx.writeAndFlush(MessageBuilder
                         .createResponse((CoapRequest) msg, responseStatus));
                         : ResponseStatus.UNAUTHORIZED;
                 ctx.writeAndFlush(MessageBuilder
                         .createResponse((CoapRequest) msg, responseStatus));
-                Log.f(ctx.channel(), t);
+                Log.error("[{}] channel error", ctx.channel().id().asLongText().substring(26), t);
             }
         }
     }
             }
         }
     }
@@ -552,7 +553,7 @@ public class DeviceServerSystem extends ServerSystem {
                     ctx.writeAndFlush(MessageBuilder.createSignalingResponse(
                             (CoapSignaling) msg, responseStatus));
                 }
                     ctx.writeAndFlush(MessageBuilder.createSignalingResponse(
                             (CoapSignaling) msg, responseStatus));
                 }
-                Log.f(ctx.channel(), t);
+                Log.error("[{}] channel error", ctx.channel().id().asLongText().substring(26), t);
             }
         }
 
             }
         }
 
diff --git a/cloud/interface/src/main/resources/logback.xml b/cloud/interface/src/main/resources/logback.xml
new file mode 100644 (file)
index 0000000..9f4a48c
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!-- To log coap message payload, include variable %X{coappayload} into pattern -->
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} | %-5level | %class{0}.%method:%L | %msg%n</pattern>
+        </encoder>
+    </appender>
+    <root level="trace">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
index 05523da..12857b1 100644 (file)
@@ -56,7 +56,6 @@ import org.iotivity.cloud.ciserver.resources.proxy.rd.ResourceDirectory;
 import org.iotivity.cloud.ciserver.resources.proxy.rd.ResourceFind;
 import org.iotivity.cloud.ciserver.resources.proxy.rd.ResourcePresence;
 import org.iotivity.cloud.util.Cbor;
 import org.iotivity.cloud.ciserver.resources.proxy.rd.ResourceFind;
 import org.iotivity.cloud.ciserver.resources.proxy.rd.ResourcePresence;
 import org.iotivity.cloud.util.Cbor;
-import org.iotivity.cloud.util.Log;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -108,7 +107,6 @@ public class DeviceServerSystemTest {
 
     @Before
     public void setUp() throws Exception {
 
     @Before
     public void setUp() throws Exception {
-        Log.createfile();
         MockitoAnnotations.initMocks(this);
         mRes = null;
         mReq = null;
         MockitoAnnotations.initMocks(this);
         mRes = null;
         mReq = null;
index 3b1fac1..b6e9d99 100644 (file)
@@ -24,34 +24,29 @@ package org.iotivity.cloud.mqserver;
 import java.net.InetSocketAddress;
 import java.util.Scanner;
 
 import java.net.InetSocketAddress;
 import java.util.Scanner;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.ServerSystem;
 import org.iotivity.cloud.base.resource.CloudPingResource;
 import org.iotivity.cloud.base.server.CoapServer;
 import org.iotivity.cloud.mqserver.resources.MQBrokerResource;
 import org.iotivity.cloud.base.ServerSystem;
 import org.iotivity.cloud.base.resource.CloudPingResource;
 import org.iotivity.cloud.base.server.CoapServer;
 import org.iotivity.cloud.mqserver.resources.MQBrokerResource;
-import org.iotivity.cloud.util.Log;
 
 public class MessageQueueServer {
 
 public class MessageQueueServer {
-
-    private static int     coapServerPort;
-    private static boolean tlsMode;
-    private static String  zookeeperHost;
-    private static String  kafkaHost;
-    private static String  webLogHost;
+    private final static Logger     Log                 = LoggerFactory.getLogger(MessageQueueServer.class);
+    private static int              coapServerPort;
+    private static boolean          tlsMode;
+    private static String           zookeeperHost;
+    private static String           kafkaHost;
 
     public static void main(String[] args) throws Exception {
 
     public static void main(String[] args) throws Exception {
-        System.out.println("-----MQ SERVER-----");
-        Log.Init();
+        Log.info("Starting Message Queue Server");
 
         if (!parseConfiguration(args)) {
 
         if (!parseConfiguration(args)) {
-            Log.e("\nCoAP-server <Port> Zookeeper <Address> <Port> Kafka <Address> <Port> TLS-mode <0|1> are required. "
-                    + "WebSocketLog-Server <Addres> <Port> is optional.\n"
+            Log.error("\nCoAP-server <Port> Zookeeper <Address> <Port> Kafka <Address> <Port> TLS-mode <0|1> are required.\n"
                     + "ex) " + Constants.DEFAULT_COAP_PORT
                     + " 127.0.0.1 2181 127.0.0.1 9092 0\n");
             return;
         }
                     + "ex) " + Constants.DEFAULT_COAP_PORT
                     + " 127.0.0.1 2181 127.0.0.1 9092 0\n");
             return;
         }
-        if (webLogHost != null)
-            Log.InitWebLog(webLogHost,
-                    MessageQueueServer.class.getSimpleName().toString());
 
         ServerSystem serverSystem = new ServerSystem();
 
 
         ServerSystem serverSystem = new ServerSystem();
 
@@ -83,13 +78,11 @@ public class MessageQueueServer {
 
     private static boolean parseConfiguration(String[] args) {
         // configuration provided by arguments
 
     private static boolean parseConfiguration(String[] args) {
         // configuration provided by arguments
-        if (args.length == 6 || args.length == 8) {
+        if (args.length == 6) {
             coapServerPort = Integer.parseInt(args[0]);
             zookeeperHost = args[1] + ":" + args[2];
             kafkaHost = args[3] + ":" + args[4];
             tlsMode = Integer.parseInt(args[5]) == 1;
             coapServerPort = Integer.parseInt(args[0]);
             zookeeperHost = args[1] + ":" + args[2];
             kafkaHost = args[3] + ":" + args[4];
             tlsMode = Integer.parseInt(args[5]) == 1;
-            if (args.length == 8)
-                webLogHost = args[6] + ":" + args[7];
             return true;
         }
         // configuration provided by docker env
             return true;
         }
         // configuration provided by docker env
index 052bc14..150ea1f 100644 (file)
@@ -23,8 +23,9 @@ package org.iotivity.cloud.mqserver;
 
 import java.util.HashMap;
 
 
 import java.util.HashMap;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.util.Cbor;
 import org.iotivity.cloud.util.Cbor;
-import org.iotivity.cloud.util.Log;
 
 /**
  * 
 
 /**
  * 
@@ -32,6 +33,7 @@ import org.iotivity.cloud.util.Log;
  *
  */
 public class MessageQueueUtils {
  *
  */
 public class MessageQueueUtils {
+    private final static Logger Log             = LoggerFactory.getLogger(MessageQueueUtils.class);
 
     /**
      * API to get data in the payload with specific property key
 
     /**
      * API to get data in the payload with specific property key
@@ -46,7 +48,7 @@ public class MessageQueueUtils {
     public static <T> T extractDataFromPayload(byte[] payload, String key) {
 
         if (payload == null || key.isEmpty()) {
     public static <T> T extractDataFromPayload(byte[] payload, String key) {
 
         if (payload == null || key.isEmpty()) {
-            Log.e("payload or key is empty");
+            Log.error("payload or key is empty");
             return null;
         }
 
             return null;
         }
 
@@ -56,7 +58,7 @@ public class MessageQueueUtils {
         parsedData = cbor.parsePayloadFromCbor(payload, HashMap.class);
 
         if (parsedData == null || parsedData.containsKey(key) == false) {
         parsedData = cbor.parsePayloadFromCbor(payload, HashMap.class);
 
         if (parsedData == null || parsedData.containsKey(key) == false) {
-            Log.e("payload doesn't contain " + key + " information");
+            Log.error("payload doesn't contain " + key + " information");
             return null;
         }
 
             return null;
         }
 
index dfc9458..f699a24 100644 (file)
@@ -29,8 +29,9 @@ import kafka.utils.ZkUtils;
 
 import org.I0Itec.zkclient.ZkClient;
 import org.I0Itec.zkclient.ZkConnection;
 
 import org.I0Itec.zkclient.ZkClient;
 import org.I0Itec.zkclient.ZkConnection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.mqserver.Constants;
 import org.iotivity.cloud.mqserver.Constants;
-import org.iotivity.cloud.util.Log;
 
 /**
  *
 
 /**
  *
@@ -38,9 +39,9 @@ import org.iotivity.cloud.util.Log;
  *
  */
 public class KafkaCommonWrapper {
  *
  */
 public class KafkaCommonWrapper {
-
-    private ZkClient mZkClient = null;
-    private ZkUtils  mZkUtils  = null;
+    private final static Logger     Log             = LoggerFactory.getLogger(KafkaCommonWrapper.class);
+    private ZkClient                mZkClient       = null;
+    private ZkUtils                 mZkUtils        = null;
 
     public KafkaCommonWrapper(String zookeeperAddress, String brokerAddress) {
 
 
     public KafkaCommonWrapper(String zookeeperAddress, String brokerAddress) {
 
@@ -63,7 +64,7 @@ public class KafkaCommonWrapper {
      */
     public boolean createTopic(String topic) {
 
      */
     public boolean createTopic(String topic) {
 
-        Log.d("kafka createTopic - " + topic);
+        Log.debug("kafka createTopic - " + topic);
 
         topic = topic.replace('/', '.');
 
 
         topic = topic.replace('/', '.');
 
@@ -89,7 +90,7 @@ public class KafkaCommonWrapper {
      */
     public boolean deleteTopic(String topic) {
 
      */
     public boolean deleteTopic(String topic) {
 
-        Log.d("kafka deleteTopic - " + topic);
+        Log.debug("kafka deleteTopic - " + topic);
 
         topic = topic.replace('/', '.');
 
 
         topic = topic.replace('/', '.');
 
index 1ff5224..f688300 100644 (file)
@@ -32,9 +32,10 @@ import java.util.concurrent.Executors;
 
 import org.I0Itec.zkclient.ZkClient;
 import org.I0Itec.zkclient.ZkConnection;
 
 import org.I0Itec.zkclient.ZkClient;
 import org.I0Itec.zkclient.ZkConnection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.mqserver.Constants;
 import org.iotivity.cloud.mqserver.topic.Topic;
 import org.iotivity.cloud.mqserver.Constants;
 import org.iotivity.cloud.mqserver.topic.Topic;
-import org.iotivity.cloud.util.Log;
 
 import kafka.admin.AdminUtils;
 import kafka.api.FetchRequest;
 
 import kafka.admin.AdminUtils;
 import kafka.api.FetchRequest;
@@ -61,21 +62,21 @@ import kafka.utils.ZkUtils;
  *
  */
 public class KafkaConsumerWrapper {
  *
  */
 public class KafkaConsumerWrapper {
+    private final static Logger     Log                = LoggerFactory.getLogger(KafkaConsumerWrapper.class);
+    private String                  mTopicName         = null;
 
 
-    private String            mTopicName         = null;
+    private String                  mZookeeper         = null;
+    private String                  mBroker            = null;
 
 
-    private String            mZookeeper         = null;
-    private String            mBroker            = null;
+    private ZkClient                mZkClient          = null;
+    private ZkUtils                 mZkUtils           = null;
 
 
-    private ZkClient          mZkClient          = null;
-    private ZkUtils           mZkUtils           = null;
+    private ConsumerConnector       mConsumerConnector = null;
+    private ExecutorService         mConsumerExecutor  = null;
 
 
-    private ConsumerConnector mConsumerConnector = null;
-    private ExecutorService   mConsumerExecutor  = null;
+    private Topic                   mInternalConsumer  = null;
 
 
-    private Topic             mInternalConsumer  = null;
-
-    private boolean           mConsumerStarted   = false;
+    private boolean                 mConsumerStarted   = false;
 
     public KafkaConsumerWrapper(String zookeeperAddress, String brokerAddress,
             Topic consumer) {
 
     public KafkaConsumerWrapper(String zookeeperAddress, String brokerAddress,
             Topic consumer) {
@@ -111,7 +112,7 @@ public class KafkaConsumerWrapper {
      */
     public boolean subscribeTopic() {
 
      */
     public boolean subscribeTopic() {
 
-        Log.d("kafka subscribeTopic - " + mTopicName);
+        Log.debug("kafka subscribeTopic - " + mTopicName);
 
         if (mConsumerStarted == true) {
             return true;
 
         if (mConsumerStarted == true) {
             return true;
@@ -144,7 +145,7 @@ public class KafkaConsumerWrapper {
 
         for (final KafkaStream<byte[], byte[]> stream : streams) {
 
 
         for (final KafkaStream<byte[], byte[]> stream : streams) {
 
-            Log.d("kafka subscribe complete");
+            Log.debug("kafka subscribe complete");
 
             mConsumerExecutor.execute(new Runnable() {
 
 
             mConsumerExecutor.execute(new Runnable() {
 
@@ -172,7 +173,7 @@ public class KafkaConsumerWrapper {
      */
     public boolean unsubscribeTopic() {
 
      */
     public boolean unsubscribeTopic() {
 
-        Log.d("kafka unsubscribeTopic - " + mTopicName);
+        Log.debug("kafka unsubscribeTopic - " + mTopicName);
 
         // remove consumer group info in zookeeper
         List<String> subscribers = mZkClient
 
         // remove consumer group info in zookeeper
         List<String> subscribers = mZkClient
@@ -210,13 +211,13 @@ public class KafkaConsumerWrapper {
      */
     public ArrayList<byte[]> getMessages() {
 
      */
     public ArrayList<byte[]> getMessages() {
 
-        Log.d("kafka get all messages - " + mTopicName);
+        Log.debug("kafka get all messages - " + mTopicName);
 
         String brokerHost = mBroker.substring(0, mBroker.indexOf(':'));
         int brokerPort = Integer
                 .parseInt(mBroker.substring(mBroker.indexOf(':') + 1));
 
 
         String brokerHost = mBroker.substring(0, mBroker.indexOf(':'));
         int brokerPort = Integer
                 .parseInt(mBroker.substring(mBroker.indexOf(':') + 1));
 
-        Log.d("host " + brokerHost + ", port " + brokerPort);
+        Log.debug("host " + brokerHost + ", port " + brokerPort);
 
         // TODO check options - Timeout: Int, bufferSize: Int
         SimpleConsumer simpleConsumer = new SimpleConsumer(brokerHost,
 
         // TODO check options - Timeout: Int, bufferSize: Int
         SimpleConsumer simpleConsumer = new SimpleConsumer(brokerHost,
@@ -233,7 +234,7 @@ public class KafkaConsumerWrapper {
 
         if (fetchResponse == null || fetchResponse.hasError()) {
 
 
         if (fetchResponse == null || fetchResponse.hasError()) {
 
-            Log.e("Error fetching data from the Broker");
+            Log.error("Error fetching data from the Broker");
             return null;
         }
 
             return null;
         }
 
@@ -247,7 +248,7 @@ public class KafkaConsumerWrapper {
 
                 long currentOffset = messageAndOffset.offset();
                 if (currentOffset < lastOffset) {
 
                 long currentOffset = messageAndOffset.offset();
                 if (currentOffset < lastOffset) {
-                    Log.e("Found an old offset: " + currentOffset
+                    Log.error("Found an old offset: " + currentOffset
                             + " Expecting: " + lastOffset);
                     continue;
                 }
                             + " Expecting: " + lastOffset);
                     continue;
                 }
@@ -266,7 +267,7 @@ public class KafkaConsumerWrapper {
 
         simpleConsumer.close();
 
 
         simpleConsumer.close();
 
-        Log.d("kafka get all messages complete");
+        Log.debug("kafka get all messages complete");
 
         return initialData;
     }
 
         return initialData;
     }
@@ -301,7 +302,7 @@ public class KafkaConsumerWrapper {
         OffsetResponse response = consumer.getOffsetsBefore(request);
 
         if (response == null || response.hasError()) {
         OffsetResponse response = consumer.getOffsetsBefore(request);
 
         if (response == null || response.hasError()) {
-            Log.e("Error fetching data Offset Data the Broker");
+            Log.error("Error fetching data Offset Data the Broker");
             return 0;
         }
 
             return 0;
         }
 
index 164baf9..cf9d7d8 100644 (file)
@@ -26,7 +26,8 @@ import java.util.Properties;
 import org.apache.kafka.clients.producer.KafkaProducer;
 import org.apache.kafka.clients.producer.Producer;
 import org.apache.kafka.clients.producer.ProducerRecord;
 import org.apache.kafka.clients.producer.KafkaProducer;
 import org.apache.kafka.clients.producer.Producer;
 import org.apache.kafka.clients.producer.ProducerRecord;
-import org.iotivity.cloud.util.Log;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  *
 
 /**
  *
@@ -35,7 +36,7 @@ import org.iotivity.cloud.util.Log;
  *
  */
 public class KafkaProducerWrapper {
  *
  */
 public class KafkaProducerWrapper {
-
+    private final static Logger      Log        = LoggerFactory.getLogger(KafkaProducerWrapper.class);
     private String                   mTopicName = null;
     private String                   mBroker    = null;
 
     private String                   mTopicName = null;
     private String                   mBroker    = null;
 
@@ -61,7 +62,7 @@ public class KafkaProducerWrapper {
      */
     public boolean publishMessage(byte[] message) {
 
      */
     public boolean publishMessage(byte[] message) {
 
-        Log.d("kafka publishMessage - " + mTopicName);
+        Log.debug("kafka publishMessage - " + mTopicName);
 
         ProducerRecord<byte[], byte[]> record = new ProducerRecord<>(
                 mTopicName, message);
 
         ProducerRecord<byte[], byte[]> record = new ProducerRecord<>(
                 mTopicName, message);
diff --git a/cloud/messagequeue/src/main/resources/logback.xml b/cloud/messagequeue/src/main/resources/logback.xml
new file mode 100644 (file)
index 0000000..9f4a48c
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!-- To log coap message payload, include variable %X{coappayload} into pattern -->
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} | %-5level | %class{0}.%method:%L | %msg%n</pattern>
+        </encoder>
+    </appender>
+    <root level="trace">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
index dc24b81..24c33cb 100644 (file)
         <version>1.0.1</version>
       </dependency>
 
         <version>1.0.1</version>
       </dependency>
 
-      <!-- Logging -->
-      <dependency>
-        <groupId>log4j</groupId>
-        <artifactId>log4j</artifactId>
-        <version>1.2.17</version>
-      </dependency>
-
       <!-- Testing -->
       <dependency>
         <groupId>junit</groupId>
       <!-- Testing -->
       <dependency>
         <groupId>junit</groupId>
index 5667694..dcf4e0e 100644 (file)
@@ -24,6 +24,8 @@ package org.iotivity.cloud.rdserver;
 import java.net.InetSocketAddress;
 import java.util.Scanner;
 
 import java.net.InetSocketAddress;
 import java.util.Scanner;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.ServerSystem;
 import org.iotivity.cloud.base.resource.CloudPingResource;
 import org.iotivity.cloud.base.server.CoapServer;
 import org.iotivity.cloud.base.ServerSystem;
 import org.iotivity.cloud.base.resource.CloudPingResource;
 import org.iotivity.cloud.base.server.CoapServer;
@@ -32,7 +34,6 @@ import org.iotivity.cloud.rdserver.resources.directory.rd.ResourceDirectoryResou
 import org.iotivity.cloud.rdserver.resources.directory.res.DiscoveryResource;
 import org.iotivity.cloud.rdserver.resources.presence.device.DevicePresenceResource;
 import org.iotivity.cloud.rdserver.resources.presence.resource.ResPresenceResource;
 import org.iotivity.cloud.rdserver.resources.directory.res.DiscoveryResource;
 import org.iotivity.cloud.rdserver.resources.presence.device.DevicePresenceResource;
 import org.iotivity.cloud.rdserver.resources.presence.resource.ResPresenceResource;
-import org.iotivity.cloud.util.Log;
 
 /**
  *
 
 /**
  *
@@ -40,25 +41,20 @@ import org.iotivity.cloud.util.Log;
  *
  */
 public class ResourceDirectoryServer {
  *
  */
 public class ResourceDirectoryServer {
-
-    private static int     coapServerPort;
-    private static boolean tlsMode;
-    private static String  databaseHost;
-    private static String  webLogHost;
+    private final static Logger     Log             = LoggerFactory.getLogger(ResourceDirectoryServer.class);
+    private static int              coapServerPort;
+    private static boolean          tlsMode;
+    private static String           databaseHost;
 
     public static void main(String[] args) throws Exception {
 
     public static void main(String[] args) throws Exception {
-        System.out.println("-----RD SERVER-----");
-        Log.Init();
+        Log.info("Starting Resource Directory Server");
 
         if (!parseConfiguration(args)) {
 
         if (!parseConfiguration(args)) {
-            Log.e("\nCoAP-server <Port> Database <Address> <Port> TLS-mode <0|1> are required. WebSocketLog-Server <Addres> <Port> is optional.\n"
+            Log.error("\nCoAP-server <Port> Database <Address> <Port> TLS-mode <0|1> are required.\n"
                     + "ex) " + Constants.DEFAULT_COAP_PORT
                     + " 127.0.0.1 27017 0\n");
             return;
         }
                     + "ex) " + Constants.DEFAULT_COAP_PORT
                     + " 127.0.0.1 27017 0\n");
             return;
         }
-        if (webLogHost != null)
-            Log.InitWebLog(webLogHost,
-                    ResourceDirectoryServer.class.getSimpleName().toString());
 
         DBManager.createInstance(databaseHost);
 
 
         DBManager.createInstance(databaseHost);
 
@@ -92,12 +88,10 @@ public class ResourceDirectoryServer {
 
     private static boolean parseConfiguration(String[] args) {
         // configuration provided by arguments
 
     private static boolean parseConfiguration(String[] args) {
         // configuration provided by arguments
-        if (args.length == 4 || args.length == 6) {
+        if (args.length == 4) {
             coapServerPort = Integer.parseInt(args[0]);
             databaseHost = args[1] + ":" + args[2];
             tlsMode = Integer.parseInt(args[3]) == 1;
             coapServerPort = Integer.parseInt(args[0]);
             databaseHost = args[1] + ":" + args[2];
             tlsMode = Integer.parseInt(args[3]) == 1;
-            if (args.length == 6)
-                webLogHost = args[4] + ":" + args[5];
             return true;
         }
         // configuration provided by docker env
             return true;
         }
         // configuration provided by docker env
index 8955edc..f7cc46f 100644 (file)
@@ -28,8 +28,9 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
 import java.util.Map.Entry;
 import java.util.Set;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.bson.Document;
 import org.bson.Document;
-import org.iotivity.cloud.util.Log;
 
 import com.mongodb.MongoClient;
 import com.mongodb.client.MongoCollection;
 
 import com.mongodb.MongoClient;
 import com.mongodb.client.MongoCollection;
@@ -43,7 +44,7 @@ import com.mongodb.client.model.IndexOptions;
  *
  */
 public class MongoDB {
  *
  */
 public class MongoDB {
-
+    private final static Logger Log   = LoggerFactory.getLogger(MongoDB.class);
     private MongoClient   mongoClient = null;
     private MongoDatabase db          = null;
 
     private MongoClient   mongoClient = null;
     private MongoDatabase db          = null;
 
@@ -141,7 +142,7 @@ public class MongoDB {
 
             } else {
 
 
             } else {
 
-                Log.w("DB insert failed due to duplecated one.");
+                Log.warn("DB insert failed due to duplecated one.");
                 return false;
             }
 
                 return false;
             }
 
@@ -217,7 +218,7 @@ public class MongoDB {
 
         if (collection.findOneAndReplace(filter, record) == null) {
 
 
         if (collection.findOneAndReplace(filter, record) == null) {
 
-            Log.w("DB update failed due to no matched record!");
+            Log.warn("DB update failed due to no matched record!");
             return false;
         }
 
             return false;
         }
 
@@ -321,7 +322,7 @@ public class MongoDB {
         MongoCollection<Document> collection = db.getCollection(tableName);
         MongoCursor<Document> cursor = collection.find().iterator();
 
         MongoCollection<Document> collection = db.getCollection(tableName);
         MongoCursor<Document> cursor = collection.find().iterator();
 
-        Log.i("<" + tableName + ">");
+        Log.info("<" + tableName + ">");
 
         HashMap<String, Object> records = null;
         int index = 0;
 
         HashMap<String, Object> records = null;
         int index = 0;
@@ -330,7 +331,7 @@ public class MongoDB {
             Document doc = cursor.next();
             records = convertDocumentToHashMap(doc);
 
             Document doc = cursor.next();
             records = convertDocumentToHashMap(doc);
 
-            Log.i("[" + index + "] " + records.toString());
+            Log.info("[" + index + "] " + records.toString());
             index++;
         }
 
             index++;
         }
 
index 92f30d2..5ac2143 100644 (file)
@@ -25,11 +25,12 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
 import java.util.HashMap;
 import java.util.List;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.exception.ServerException.BadRequestException;
 import org.iotivity.cloud.rdserver.Constants;
 import org.iotivity.cloud.rdserver.db.DBManager;
 import org.iotivity.cloud.rdserver.resources.directory.rd.InsManager;
 import org.iotivity.cloud.base.exception.ServerException.BadRequestException;
 import org.iotivity.cloud.rdserver.Constants;
 import org.iotivity.cloud.rdserver.db.DBManager;
 import org.iotivity.cloud.rdserver.resources.directory.rd.InsManager;
-import org.iotivity.cloud.util.Log;
 
 /**
  * 
 
 /**
  * 
@@ -37,7 +38,7 @@ import org.iotivity.cloud.util.Log;
  *
  */
 public class RDManager {
  *
  */
 public class RDManager {
-
+    private final static Logger                Log               = LoggerFactory.getLogger(RDManager.class);
     private InsManager                         mInsManager       = new InsManager();
     private PayloadManager                     mPayloadManager   = new PayloadManager();
 
     private InsManager                         mInsManager       = new InsManager();
     private PayloadManager                     mPayloadManager   = new PayloadManager();
 
@@ -232,7 +233,7 @@ public class RDManager {
             }
         }
 
             }
         }
 
-        Log.d("discovery payload : " + response);
+        Log.debug("discovery payload : " + response);
 
         return response;
     }
 
         return response;
     }
index ce4877a..d09052e 100644 (file)
@@ -26,6 +26,8 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 
 import java.util.HashMap;
 import java.util.List;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.device.Device;
 import org.iotivity.cloud.base.exception.ServerException;
 import org.iotivity.cloud.base.exception.ServerException.BadRequestException;
 import org.iotivity.cloud.base.device.Device;
 import org.iotivity.cloud.base.exception.ServerException;
 import org.iotivity.cloud.base.exception.ServerException.BadRequestException;
@@ -40,7 +42,6 @@ import org.iotivity.cloud.rdserver.Constants;
 import org.iotivity.cloud.rdserver.resources.directory.RDManager;
 import org.iotivity.cloud.rdserver.resources.presence.PresenceManager;
 import org.iotivity.cloud.util.Cbor;
 import org.iotivity.cloud.rdserver.resources.directory.RDManager;
 import org.iotivity.cloud.rdserver.resources.presence.PresenceManager;
 import org.iotivity.cloud.util.Cbor;
-import org.iotivity.cloud.util.Log;
 
 /**
  * 
 
 /**
  * 
@@ -48,7 +49,7 @@ import org.iotivity.cloud.util.Log;
  *
  */
 public class ResourceDirectoryResource extends Resource {
  *
  */
 public class ResourceDirectoryResource extends Resource {
-
+    private final static Logger Log                  = LoggerFactory.getLogger(ResourceDirectoryResource.class);
     private Cbor<HashMap<String, Object>> mCbor      = new Cbor<>();
     private RDManager                     mRdManager = new RDManager();
 
     private Cbor<HashMap<String, Object>> mCbor      = new Cbor<>();
     private RDManager                     mRdManager = new RDManager();
 
@@ -104,7 +105,7 @@ public class ResourceDirectoryResource extends Resource {
         HashMap<String, Object> payload = mCbor
                 .parsePayloadFromCbor(request.getPayload(), HashMap.class);
 
         HashMap<String, Object> payload = mCbor
                 .parsePayloadFromCbor(request.getPayload(), HashMap.class);
 
-        Log.d("publish payload : " + payload);
+        Log.debug("publish payload : " + payload);
 
         checkPayloadException(
                 Arrays.asList(Constants.DEVICE_ID, Constants.LINKS), payload);
 
         checkPayloadException(
                 Arrays.asList(Constants.DEVICE_ID, Constants.LINKS), payload);
@@ -114,7 +115,7 @@ public class ResourceDirectoryResource extends Resource {
 
         HashMap<String, Object> response = mRdManager.publishResource(payload);
 
 
         HashMap<String, Object> response = mRdManager.publishResource(payload);
 
-        Log.d("publish response : " + response);
+        Log.debug("publish response : " + response);
 
         return MessageBuilder.createResponse(request, ResponseStatus.CHANGED,
                 ContentFormat.APPLICATION_CBOR,
 
         return MessageBuilder.createResponse(request, ResponseStatus.CHANGED,
                 ContentFormat.APPLICATION_CBOR,
index 5bb321f..0fa0c57 100644 (file)
@@ -27,6 +27,8 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 
 import java.util.HashMap;
 import java.util.List;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.device.Device;
 import org.iotivity.cloud.base.exception.ServerException.InternalServerErrorException;
 import org.iotivity.cloud.base.protocols.IRequest;
 import org.iotivity.cloud.base.device.Device;
 import org.iotivity.cloud.base.exception.ServerException.InternalServerErrorException;
 import org.iotivity.cloud.base.protocols.IRequest;
@@ -36,7 +38,6 @@ import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.rdserver.Constants;
 import org.iotivity.cloud.rdserver.db.DBManager;
 import org.iotivity.cloud.util.Cbor;
 import org.iotivity.cloud.rdserver.Constants;
 import org.iotivity.cloud.rdserver.db.DBManager;
 import org.iotivity.cloud.util.Cbor;
-import org.iotivity.cloud.util.Log;
 
 import com.fasterxml.jackson.core.JsonEncoding;
 import com.fasterxml.jackson.core.JsonGenerator;
 
 import com.fasterxml.jackson.core.JsonEncoding;
 import com.fasterxml.jackson.core.JsonGenerator;
@@ -49,6 +50,7 @@ import com.fasterxml.jackson.dataformat.cbor.CBORGenerator;
  *
  */
 public class PresenceManager {
  *
  */
 public class PresenceManager {
+    private final static Logger           Log              = LoggerFactory.getLogger(PresenceManager.class);
     private static PresenceManager        mPresenceManager = new PresenceManager();
 
     private Cbor<HashMap<String, Object>> mCbor            = new Cbor<>();
     private static PresenceManager        mPresenceManager = new PresenceManager();
 
     private Cbor<HashMap<String, Object>> mCbor            = new Cbor<>();
@@ -209,7 +211,7 @@ public class PresenceManager {
             prsList.add(payloadSegment);
         }
         getPayload.put(Constants.PRESENCE_LIST, prsList);
             prsList.add(payloadSegment);
         }
         getPayload.put(Constants.PRESENCE_LIST, prsList);
-        Log.i("Device presence observe response : " + getPayload.toString());
+        Log.info("Device presence observe response : " + getPayload.toString());
 
         return mCbor.encodingPayloadToCbor(getPayload);
 
 
         return mCbor.encodingPayloadToCbor(getPayload);
 
diff --git a/cloud/resourcedirectory/src/main/resources/logback.xml b/cloud/resourcedirectory/src/main/resources/logback.xml
new file mode 100644 (file)
index 0000000..9f4a48c
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <!-- To log coap message payload, include variable %X{coappayload} into pattern -->
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} | %-5level | %class{0}.%method:%L | %msg%n</pattern>
+        </encoder>
+    </appender>
+    <root level="trace">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
index 8bf46ce..340fae4 100644 (file)
 
                <!-- Logging -->
                <dependency>
 
                <!-- Logging -->
                <dependency>
-                       <groupId>log4j</groupId>
-                       <artifactId>log4j</artifactId>
+                       <groupId>ch.qos.logback</groupId>
+                       <artifactId>logback-classic</artifactId>
+                       <version>1.2.3</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.slf4j</groupId>
+                       <artifactId>jul-to-slf4j</artifactId>
+                       <version>1.7.25</version>
                </dependency>
 
                <!-- Testing -->
                </dependency>
 
                <!-- Testing -->
index ddd8481..ed1ea16 100644 (file)
@@ -29,6 +29,8 @@ import io.netty.util.AttributeKey;
 import java.util.ArrayList;
 import java.util.List;
 
 import java.util.ArrayList;
 import java.util.List;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.connector.CoapClient;
 import org.iotivity.cloud.base.device.CoapDevice;
 import org.iotivity.cloud.base.device.Device;
 import org.iotivity.cloud.base.connector.CoapClient;
 import org.iotivity.cloud.base.device.CoapDevice;
 import org.iotivity.cloud.base.device.Device;
@@ -47,16 +49,11 @@ import org.iotivity.cloud.base.server.CoapServer;
 import org.iotivity.cloud.base.server.HttpServer;
 import org.iotivity.cloud.base.server.Server;
 import org.iotivity.cloud.base.server.WebSocketServer;
 import org.iotivity.cloud.base.server.HttpServer;
 import org.iotivity.cloud.base.server.Server;
 import org.iotivity.cloud.base.server.WebSocketServer;
-import org.iotivity.cloud.util.Log;
-
-import io.netty.channel.ChannelHandler.Sharable;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.SimpleChannelInboundHandler;
-import io.netty.util.AttributeKey;
 
 public class ServerSystem extends ResourceManager {
 
 public class ServerSystem extends ResourceManager {
-    private List<Server>               mServerList = new ArrayList<>();
-    public static AttributeKey<Device> keyDevice   = AttributeKey
+    private final static Logger         Log          = LoggerFactory.getLogger(ServerSystem.class);
+    private List<Server>                mServerList  = new ArrayList<>();
+    public static AttributeKey<Device>  keyDevice    = AttributeKey
             .newInstance("device");
 
     @Sharable
             .newInstance("device");
 
     @Sharable
@@ -103,11 +100,11 @@ public class ServerSystem extends ResourceManager {
             } catch (ServerException e) {
                 ctx.writeAndFlush(MessageBuilder.createResponse(msg,
                         e.getErrorResponse()));
             } catch (ServerException e) {
                 ctx.writeAndFlush(MessageBuilder.createResponse(msg,
                         e.getErrorResponse()));
-                Log.f(ctx.channel(), e);
+                Log.error("[{}] channel error", ctx.channel().id().asLongText().substring(26), e);
             } catch (ClientException e) {
             } catch (ClientException e) {
-                Log.f(ctx.channel(), e);
+                Log.error("[{}] channel error", ctx.channel().id().asLongText().substring(26), e);
             } catch (Throwable t) {
             } catch (Throwable t) {
-                Log.f(ctx.channel(), t);
+                Log.error("[{}] channel error", ctx.channel().id().asLongText().substring(26), t);
                 if (msg instanceof CoapRequest) {
                     ctx.writeAndFlush(MessageBuilder.createResponse(msg,
                             ResponseStatus.INTERNAL_SERVER_ERROR));
                 if (msg instanceof CoapRequest) {
                     ctx.writeAndFlush(MessageBuilder.createResponse(msg,
                             ResponseStatus.INTERNAL_SERVER_ERROR));
@@ -140,11 +137,11 @@ public class ServerSystem extends ResourceManager {
                 onRequestReceived(targetDevice, msg);
 
             } catch (ServerException e) {
                 onRequestReceived(targetDevice, msg);
 
             } catch (ServerException e) {
-                Log.f(ctx.channel(), e);
+                Log.error("[{}] channel error", ctx.channel().id().asLongText().substring(26), e);
                 ctx.writeAndFlush(MessageBuilder.createResponse(msg,
                         e.getErrorResponse()));
             } catch (Throwable t) {
                 ctx.writeAndFlush(MessageBuilder.createResponse(msg,
                         e.getErrorResponse()));
             } catch (Throwable t) {
-                Log.f(ctx.channel(), t);
+                Log.error("[{}] channel error", ctx.channel().id().asLongText().substring(26), t);
                 ctx.writeAndFlush(MessageBuilder.createResponse(msg,
                         ResponseStatus.INTERNAL_SERVER_ERROR));
             }
                 ctx.writeAndFlush(MessageBuilder.createResponse(msg,
                         ResponseStatus.INTERNAL_SERVER_ERROR));
             }
index 818914d..773e57f 100644 (file)
@@ -23,6 +23,8 @@ package org.iotivity.cloud.base.connector;
 
 import java.util.HashMap;
 
 
 import java.util.HashMap;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.OICConstants;
 import org.iotivity.cloud.base.device.IRequestChannel;
 import org.iotivity.cloud.base.device.IResponseEventHandler;
 import org.iotivity.cloud.base.OICConstants;
 import org.iotivity.cloud.base.device.IRequestChannel;
 import org.iotivity.cloud.base.device.IResponseEventHandler;
@@ -34,7 +36,6 @@ import org.iotivity.cloud.base.protocols.coap.CoapRequest;
 import org.iotivity.cloud.base.protocols.coap.CoapResponse;
 import org.iotivity.cloud.base.protocols.enums.Observe;
 import org.iotivity.cloud.util.Bytes;
 import org.iotivity.cloud.base.protocols.coap.CoapResponse;
 import org.iotivity.cloud.base.protocols.enums.Observe;
 import org.iotivity.cloud.util.Bytes;
-import org.iotivity.cloud.util.Log;
 
 import io.netty.channel.Channel;
 
 
 import io.netty.channel.Channel;
 
@@ -55,6 +56,9 @@ public class CoapClient implements IRequestChannel, IResponseEventHandler {
         }
     }
 
         }
     }
 
+
+
+    private final static Logger Log                    = LoggerFactory.getLogger(CoapClient.class);
     private HashMap<Long, RequestInfo> mTokenExchanger = new HashMap<>();
     private Long                       mToken          = 0L;
     private Channel                    mChannel        = null;
     private HashMap<Long, RequestInfo> mTokenExchanger = new HashMap<>();
     private Long                       mToken          = 0L;
     private Channel                    mChannel        = null;
@@ -111,7 +115,7 @@ public class CoapClient implements IRequestChannel, IResponseEventHandler {
             mChannel.writeAndFlush(request);
 
         } catch (Exception e) {
             mChannel.writeAndFlush(request);
 
         } catch (Exception e) {
-            Log.f(mChannel, e);
+            Log.error("Problem occured on channel " + mChannel.id().asLongText().substring(26), e);
         }
     }
 
         }
     }
 
index 281082a..cd33ed0 100644 (file)
@@ -33,10 +33,11 @@ import io.netty.handler.ssl.SslProvider;
 import io.netty.handler.timeout.IdleState;
 import io.netty.handler.timeout.IdleStateEvent;
 import io.netty.handler.timeout.IdleStateHandler;
 import io.netty.handler.timeout.IdleState;
 import io.netty.handler.timeout.IdleStateEvent;
 import io.netty.handler.timeout.IdleStateHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.OICConstants;
 import org.iotivity.cloud.base.protocols.coap.*;
 import org.iotivity.cloud.base.protocols.coap.PingMessage;
 import org.iotivity.cloud.base.OICConstants;
 import org.iotivity.cloud.base.protocols.coap.*;
 import org.iotivity.cloud.base.protocols.coap.PingMessage;
-import org.iotivity.cloud.util.Log;
 
 import javax.net.ssl.SSLException;
 import java.io.File;
 
 import javax.net.ssl.SSLException;
 import java.io.File;
@@ -44,7 +45,7 @@ import java.net.InetSocketAddress;
 import java.util.*;
 
 public class CoapConnector {
 import java.util.*;
 
 public class CoapConnector {
-
+    private final static Logger Log             = LoggerFactory.getLogger(CoapConnector.class);
     public CoapConnector() {
 
         mBootstrap.group(mConnectorGroup);
     public CoapConnector() {
 
         mBootstrap.group(mConnectorGroup);
@@ -75,7 +76,7 @@ public class CoapConnector {
                     ctx.writeAndFlush(PingMessage.build());
                 }
                 if (event.state() == IdleState.READER_IDLE) {
                     ctx.writeAndFlush(PingMessage.build());
                 }
                 if (event.state() == IdleState.READER_IDLE) {
-                    Log.d("Connection with" +  ctx.channel().remoteAddress().toString() + "is idle. Closing connection.");
+                    Log.debug("Connection with" +  ctx.channel().remoteAddress().toString() + "is idle. Closing connection.");
                     ctx.close();
                 }
             }
                     ctx.close();
                 }
             }
@@ -177,7 +178,7 @@ public class CoapConnector {
         mBootstrap.connect(inetSocketAddress).addListener(new ChannelFutureListener() {
                 @Override public void operationComplete(ChannelFuture future) throws Exception {
                     if(!future.isSuccess()) {
         mBootstrap.connect(inetSocketAddress).addListener(new ChannelFutureListener() {
                 @Override public void operationComplete(ChannelFuture future) throws Exception {
                     if(!future.isSuccess()) {
-                        Log.d("Connection to " + inetSocketAddress.getHostString() + " was not successful. Retrying...");
+                        Log.debug("Connection to " + inetSocketAddress.getHostString() + " was not successful. Retrying...");
                         future.channel().close();
                         scheduleConnect(connectionName, inetSocketAddress, tlsMode, 5000);
                     } else {
                         future.channel().close();
                         scheduleConnect(connectionName, inetSocketAddress, tlsMode, 5000);
                     } else {
@@ -188,7 +189,7 @@ public class CoapConnector {
 
             private void addCloseDetectListener(Channel channel) {
                 channel.closeFuture().addListener((ChannelFutureListener) future -> {
 
             private void addCloseDetectListener(Channel channel) {
                 channel.closeFuture().addListener((ChannelFutureListener) future -> {
-                    Log.d("Connection to " + inetSocketAddress.getHostString() + " was lost. Retrying...");
+                    Log.debug("Connection to " + inetSocketAddress.getHostString() + " was lost. Retrying...");
                     scheduleConnect(connectionName, inetSocketAddress, tlsMode, 5);
                 });
             }
                     scheduleConnect(connectionName, inetSocketAddress, tlsMode, 5);
                 });
             }
index a22b5ba..c57627a 100644 (file)
@@ -27,6 +27,8 @@ import java.util.Iterator;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.connector.CoapClient;
 import org.iotivity.cloud.base.connector.ConnectorPool;
 import org.iotivity.cloud.base.exception.ClientException;
 import org.iotivity.cloud.base.connector.CoapClient;
 import org.iotivity.cloud.base.connector.ConnectorPool;
 import org.iotivity.cloud.base.exception.ClientException;
@@ -38,11 +40,11 @@ import org.iotivity.cloud.base.protocols.coap.CoapResponse;
 import org.iotivity.cloud.base.protocols.enums.Observe;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.util.Bytes;
 import org.iotivity.cloud.base.protocols.enums.Observe;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.util.Bytes;
-import org.iotivity.cloud.util.Log;
 
 import io.netty.channel.ChannelHandlerContext;
 
 public class CoapDevice extends Device {
 
 import io.netty.channel.ChannelHandlerContext;
 
 public class CoapDevice extends Device {
+    private final static Logger        Log                 = LoggerFactory.getLogger(CoapDevice.class);
     private CoapClient                 mCoapClient         = null;
     private String                     mUserId             = null;
     private String                     mDeviceId           = null;
     private CoapClient                 mCoapClient         = null;
     private String                     mUserId             = null;
     private String                     mDeviceId           = null;
@@ -174,7 +176,7 @@ public class CoapDevice extends Device {
 
         if (remainTime < 0) {
 
 
         if (remainTime < 0) {
 
-            Log.w("accessToken is expired..");
+            Log.warn("accessToken is expired..");
             return true;
         }
 
             return true;
         }
 
index 9bf0332..f476ec5 100644 (file)
@@ -23,10 +23,11 @@ package org.iotivity.cloud.base.protocols.coap;
 
 import java.util.List;
 
 
 import java.util.List;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.exception.ServerException;
 import org.iotivity.cloud.base.protocols.MessageBuilder;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.base.exception.ServerException;
 import org.iotivity.cloud.base.protocols.MessageBuilder;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
-import org.iotivity.cloud.util.Log;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
@@ -38,6 +39,7 @@ public class CoapDecoder extends ByteToMessageDecoder {
         SHIM_HEADER, OPTION_PAYLOAD_LENGTH, CODE_TOKEN_OPTION, PAYLOAD, FINISH
     }
 
         SHIM_HEADER, OPTION_PAYLOAD_LENGTH, CODE_TOKEN_OPTION, PAYLOAD, FINISH
     }
 
+    private final static Logger Log          = LoggerFactory.getLogger(CoapDecoder.class);
     private ParsingState nextState           = ParsingState.SHIM_HEADER;
     private int          bufferToRead        = 1;
     private int          tokenLength         = 0;
     private ParsingState nextState           = ParsingState.SHIM_HEADER;
     private int          bufferToRead        = 1;
     private int          tokenLength         = 0;
@@ -166,7 +168,7 @@ public class CoapDecoder extends ByteToMessageDecoder {
             ResponseStatus responseStatus = t instanceof ServerException
                     ? ((ServerException) t).getErrorResponse()
                     : ResponseStatus.INTERNAL_SERVER_ERROR;
             ResponseStatus responseStatus = t instanceof ServerException
                     ? ((ServerException) t).getErrorResponse()
                     : ResponseStatus.INTERNAL_SERVER_ERROR;
-            Log.f(ctx.channel(), t);
+            Log.error("[{}] channel error", ctx.channel().id().asLongText().substring(26), t);
             ctx.writeAndFlush(
                     MessageBuilder.createResponse(partialMsg, responseStatus));
             ctx.close();
             ctx.writeAndFlush(
                     MessageBuilder.createResponse(partialMsg, responseStatus));
             ctx.close();
index be43be5..b7e52a4 100644 (file)
@@ -23,10 +23,11 @@ package org.iotivity.cloud.base.protocols.coap;
 
 import java.util.ArrayList;
 
 
 import java.util.ArrayList;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.OICConstants;
 import org.iotivity.cloud.base.protocols.enums.ContentFormat;
 import org.iotivity.cloud.util.Cbor;
 import org.iotivity.cloud.base.OICConstants;
 import org.iotivity.cloud.base.protocols.enums.ContentFormat;
 import org.iotivity.cloud.util.Cbor;
-import org.iotivity.cloud.util.Log;
 
 import com.google.gson.Gson;
 
 
 import com.google.gson.Gson;
 
@@ -34,6 +35,7 @@ import io.netty.channel.ChannelDuplexHandler;
 import io.netty.channel.ChannelHandler.Sharable;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelPromise;
 import io.netty.channel.ChannelHandler.Sharable;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelPromise;
+import org.slf4j.MDC;
 
 /**
  *
 
 /**
  *
@@ -43,26 +45,23 @@ import io.netty.channel.ChannelPromise;
  */
 @Sharable
 public class CoapLogHandler extends ChannelDuplexHandler {
  */
 @Sharable
 public class CoapLogHandler extends ChannelDuplexHandler {
-
-    private Cbor<Object> mCbor      = new Cbor<>();
-    private Gson         mGson      = new Gson();
-
-    static final int     MAX_LOGLEN = 100;
+    private final static Logger     Log                         = LoggerFactory.getLogger(CoapLogHandler.class);
+    public static final String      COAP_MESSAGE_PAYLOAD        = "coappayload";
+    private Cbor<Object>            mCbor                       = new Cbor<>();
+    private Gson                    mGson                       = new Gson();
 
     @Override
     public void channelActive(ChannelHandlerContext ctx) throws Exception {
 
     @Override
     public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        Log.v(ctx.channel().id().asLongText().substring(26)
-                + " Connected, Address: "
-                + ctx.channel().remoteAddress().toString());
+        Log.trace("[{}] Connected, Address: {}", ctx.channel().id().asLongText().substring(26),
+                ctx.channel().remoteAddress().toString());
 
         ctx.fireChannelActive();
     }
 
     @Override
     public void channelInactive(ChannelHandlerContext ctx) throws Exception {
 
         ctx.fireChannelActive();
     }
 
     @Override
     public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        Log.v(ctx.channel().id().asLongText().substring(26)
-                + " Disconnected, Address: "
-                + ctx.channel().remoteAddress().toString());
+        Log.trace("[{}] Disconnected, Address: {}", ctx.channel().id().asLongText().substring(26),
+                ctx.channel().remoteAddress().toString());
 
         ctx.fireChannelInactive();
     }
 
         ctx.fireChannelInactive();
     }
@@ -83,7 +82,7 @@ public class CoapLogHandler extends ChannelDuplexHandler {
         }
 
         if (log != null) {
         }
 
         if (log != null) {
-            Log.v(log);
+            Log.trace(log);
         }
 
         ctx.writeAndFlush(msg);
         }
 
         ctx.writeAndFlush(msg);
@@ -105,7 +104,7 @@ public class CoapLogHandler extends ChannelDuplexHandler {
         }
 
         if (log != null) {
         }
 
         if (log != null) {
-            Log.v(log);
+            Log.trace(log);
         }
 
         ctx.fireChannelRead(msg);
         }
 
         ctx.fireChannelRead(msg);
@@ -114,31 +113,31 @@ public class CoapLogHandler extends ChannelDuplexHandler {
     private String composeCoapRequest(String channelId, CoapRequest request) {
         StringBuilder strBuilder = new StringBuilder();
 
     private String composeCoapRequest(String channelId, CoapRequest request) {
         StringBuilder strBuilder = new StringBuilder();
 
-        strBuilder.append(channelId);
-        strBuilder.append(" " + request.getTokenString());
+        strBuilder.append("[" + channelId + "]");
+        strBuilder.append(" [" + request.getTokenString() + "]");
 
         switch (request.getMethod()) {
             case DELETE:
 
         switch (request.getMethod()) {
             case DELETE:
-                strBuilder.append(" DELETE ");
+                strBuilder.append(" [DELETE] ");
                 break;
             case GET:
                 switch (request.getObserve()) {
                     case SUBSCRIBE:
                 break;
             case GET:
                 switch (request.getObserve()) {
                     case SUBSCRIBE:
-                        strBuilder.append(" GET OBSERVE ");
+                        strBuilder.append(" [GET OBSERVE] ");
                         break;
                     case UNSUBSCRIBE:
                         break;
                     case UNSUBSCRIBE:
-                        strBuilder.append(" GET OBSERVE CANCEL ");
+                        strBuilder.append(" [GET OBSERVE CANCEL] ");
                         break;
                     default:
                         break;
                     default:
-                        strBuilder.append(" GET ");
+                        strBuilder.append(" [GET] ");
                         break;
                 }
                 break;
             case POST:
                         break;
                 }
                 break;
             case POST:
-                strBuilder.append(" POST ");
+                strBuilder.append(" [POST] ");
                 break;
             case PUT:
                 break;
             case PUT:
-                strBuilder.append(" PUT ");
+                strBuilder.append(" [PUT] ");
                 break;
         }
 
                 break;
         }
 
@@ -150,8 +149,8 @@ public class CoapLogHandler extends ChannelDuplexHandler {
 
         if (request.getPayloadSize() > 0) {
             strBuilder.append(" CT:" + request.getContentFormat());
 
         if (request.getPayloadSize() > 0) {
             strBuilder.append(" CT:" + request.getContentFormat());
-            strBuilder.append(" SZ:" + request.getPayloadSize() + " P:"
-                    + getJsonPayloadString(request));
+            strBuilder.append(" SZ:" + request.getPayloadSize());
+            MDC.put(COAP_MESSAGE_PAYLOAD, "P: " + getJsonPayloadString(request));
         }
 
         return strBuilder.toString();
         }
 
         return strBuilder.toString();
@@ -161,8 +160,8 @@ public class CoapLogHandler extends ChannelDuplexHandler {
             CoapResponse response) {
         StringBuilder strBuilder = new StringBuilder();
 
             CoapResponse response) {
         StringBuilder strBuilder = new StringBuilder();
 
-        strBuilder.append(channelId);
-        strBuilder.append(" " + response.getTokenString());
+        strBuilder.append("[" + channelId + "]");
+        strBuilder.append(" [" + response.getTokenString() + "]");
 
         switch (response.getStatus()) {
             case BAD_GATEWAY:
 
         switch (response.getStatus()) {
             case BAD_GATEWAY:
@@ -249,8 +248,8 @@ public class CoapLogHandler extends ChannelDuplexHandler {
 
         if (response.getPayloadSize() > 0) {
             strBuilder.append(" CT:" + response.getContentFormat());
 
         if (response.getPayloadSize() > 0) {
             strBuilder.append(" CT:" + response.getContentFormat());
-            strBuilder.append(" SZ:" + response.getPayloadSize() + " P:"
-                    + getJsonPayloadString(response));
+            strBuilder.append(" SZ:" + response.getPayloadSize());
+            MDC.put(COAP_MESSAGE_PAYLOAD, "P: " + getJsonPayloadString(response));
         }
 
         return strBuilder.toString();
         }
 
         return strBuilder.toString();
@@ -264,13 +263,9 @@ public class CoapLogHandler extends ChannelDuplexHandler {
                     coapMessage.getPayload(), Object.class);
             if (coapMessage.getUriPath()
                     .contains(OICConstants.WELL_KNOWN_FULL_URI)) {
                     coapMessage.getPayload(), Object.class);
             if (coapMessage.getUriPath()
                     .contains(OICConstants.WELL_KNOWN_FULL_URI)) {
-                jsonPayload = mGson.toJson((ArrayList<Object>) mapPayload);
-                return jsonPayload.length() <= MAX_LOGLEN ? jsonPayload
-                        : jsonPayload.substring(0, MAX_LOGLEN);
+                return mGson.toJson((ArrayList<Object>) mapPayload);
             }
             }
-            jsonPayload = mGson.toJson(mapPayload);
-            return jsonPayload.length() <= MAX_LOGLEN ? jsonPayload
-                    : jsonPayload.substring(0, MAX_LOGLEN);
+            return mGson.toJson(mapPayload);
         }
         return jsonPayload;
     }
         }
         return jsonPayload;
     }
index f10efb2..03810f9 100644 (file)
@@ -25,6 +25,8 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
 import java.util.HashMap;
 import java.util.List;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.exception.ServerException.BadRequestException;
 import org.iotivity.cloud.base.exception.ServerException.InternalServerErrorException;
 import org.iotivity.cloud.base.protocols.coap.CoapDecoder;
 import org.iotivity.cloud.base.exception.ServerException.BadRequestException;
 import org.iotivity.cloud.base.exception.ServerException.InternalServerErrorException;
 import org.iotivity.cloud.base.protocols.coap.CoapDecoder;
@@ -33,7 +35,6 @@ import org.iotivity.cloud.base.protocols.coap.CoapMessage;
 import org.iotivity.cloud.base.protocols.enums.ContentFormat;
 import org.iotivity.cloud.util.Cbor;
 import org.iotivity.cloud.util.JSONUtil;
 import org.iotivity.cloud.base.protocols.enums.ContentFormat;
 import org.iotivity.cloud.util.Cbor;
 import org.iotivity.cloud.util.JSONUtil;
-import org.iotivity.cloud.util.Log;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
@@ -49,21 +50,20 @@ import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
 import io.netty.handler.codec.http.websocketx.WebSocketFrame;
 
 public class WebSocketFrameHandler extends ChannelDuplexHandler {
 import io.netty.handler.codec.http.websocketx.WebSocketFrame;
 
 public class WebSocketFrameHandler extends ChannelDuplexHandler {
+    private final static Logger Log = LoggerFactory.getLogger(WebSocketFrameHandler.class);
 
     @Override
     public void channelActive(ChannelHandlerContext ctx) throws Exception {
 
     @Override
     public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        Log.v(ctx.channel().id().asLongText().substring(26)
-                + " WebSocket Connected, Address: "
-                + ctx.channel().remoteAddress().toString());
+        Log.trace("[{}] WebSocket Connected, Address: {}", ctx.channel().id().asLongText().substring(26),
+                ctx.channel().remoteAddress().toString());
 
         ctx.fireChannelActive();
     }
 
     @Override
     public void channelInactive(ChannelHandlerContext ctx) throws Exception {
 
         ctx.fireChannelActive();
     }
 
     @Override
     public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        Log.v(ctx.channel().id().asLongText().substring(26)
-                + " WebSocket Disconnected, Address: "
-                + ctx.channel().remoteAddress().toString());
+        Log.trace("[{}] WebSocket Disconnected, Address: {}", ctx.channel().id().asLongText().substring(26),
+                ctx.channel().remoteAddress().toString());
 
         ctx.fireChannelInactive();
     }
 
         ctx.fireChannelInactive();
     }
@@ -114,9 +114,8 @@ public class WebSocketFrameHandler extends ChannelDuplexHandler {
                 @Override
                 public void operationComplete(ChannelFuture future)
                         throws Exception {
                 @Override
                 public void operationComplete(ChannelFuture future)
                         throws Exception {
-                    Log.v(future.channel().id().asLongText().substring(26)
-                            + " WebSocket Handshake done, Address: "
-                            + future.channel().remoteAddress().toString());
+                    Log.trace("[{}] WebSocket Handshake done, Address: {}", future.channel().id().asLongText().substring(26),
+                            future.channel().remoteAddress().toString());
 
                     // remove http encoder/decoder after handshake done.
                     future.channel().pipeline().remove(HttpServerCodec.class);
 
                     // remove http encoder/decoder after handshake done.
                     future.channel().pipeline().remove(HttpServerCodec.class);
index d8e93bf..97baf12 100644 (file)
@@ -23,9 +23,10 @@ package org.iotivity.cloud.base.protocols.http;
 
 import java.util.concurrent.ConcurrentHashMap;
 
 
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.protocols.IResponse;
 import org.iotivity.cloud.base.protocols.Message;
 import org.iotivity.cloud.base.protocols.IResponse;
 import org.iotivity.cloud.base.protocols.Message;
-import org.iotivity.cloud.util.Log;
 
 import io.netty.channel.ChannelDuplexHandler;
 import io.netty.channel.ChannelFuture;
 
 import io.netty.channel.ChannelDuplexHandler;
 import io.netty.channel.ChannelFuture;
@@ -45,7 +46,7 @@ import io.netty.util.CharsetUtil;
  * and translate them into CoAP request and HTTP response accordingly.
  */
 public class HCProxyHandler extends ChannelDuplexHandler {
  * and translate them into CoAP request and HTTP response accordingly.
  */
 public class HCProxyHandler extends ChannelDuplexHandler {
-
+    private final static Logger Log = LoggerFactory.getLogger(HCProxyHandler.class);
     private static ConcurrentHashMap<String, HCProxyProcessor> hcProxyProcessorMap
     = new ConcurrentHashMap<String, HCProxyProcessor>();
 
     private static ConcurrentHashMap<String, HCProxyProcessor> hcProxyProcessorMap
     = new ConcurrentHashMap<String, HCProxyProcessor>();
 
@@ -106,7 +107,7 @@ public class HCProxyHandler extends ChannelDuplexHandler {
 
                 if (errorStatusCode != null) {
 
 
                 if (errorStatusCode != null) {
 
-                    Log.v("HTTP Error: " + errorStatusCode);
+                    Log.trace("HTTP Error: " + errorStatusCode);
 
                     HttpResponse httpResponse = hcProxyProcessor
                             .getErrorResponse(errorStatusCode);
 
                     HttpResponse httpResponse = hcProxyProcessor
                             .getErrorResponse(errorStatusCode);
@@ -127,7 +128,7 @@ public class HCProxyHandler extends ChannelDuplexHandler {
                     errorStatusCode = "500 Internal Server Error: "
                             + "HTTP-Method does not recognized.";
 
                     errorStatusCode = "500 Internal Server Error: "
                             + "HTTP-Method does not recognized.";
 
-                    Log.v("HTTP Error: " + errorStatusCode);
+                    Log.trace("HTTP Error: " + errorStatusCode);
 
                     HttpResponse httpResponse = hcProxyProcessor
                             .getErrorResponse(errorStatusCode);
 
                     HttpResponse httpResponse = hcProxyProcessor
                             .getErrorResponse(errorStatusCode);
@@ -165,7 +166,7 @@ public class HCProxyHandler extends ChannelDuplexHandler {
                 String errorStatusCode = "500 Internal Server Error: "
                         + "HTTP response could not be generated.";
 
                 String errorStatusCode = "500 Internal Server Error: "
                         + "HTTP response could not be generated.";
 
-                Log.v("HTTP Error: " + errorStatusCode);
+                Log.trace("HTTP Error: " + errorStatusCode);
 
                 httpResponse = hcProxyProcessor
                         .getErrorResponse(errorStatusCode);
 
                 httpResponse = hcProxyProcessor
                         .getErrorResponse(errorStatusCode);
@@ -186,9 +187,9 @@ public class HCProxyHandler extends ChannelDuplexHandler {
                 if (future.isSuccess()) {
                     future.channel().close();
                 } else {
                 if (future.isSuccess()) {
                     future.channel().close();
                 } else {
-                    Log.v(ctx.channel().id().asLongText().substring(26)
-                            + " HTTP Disconnected (Unexpectedly), Address: "
-                            ctx.channel().remoteAddress().toString());
+                    Log.warn("[{}] HTTP Disconnected (Unexpectedly), Address: {}",
+                            ctx.channel().id().asLongText().substring(26),
+                            ctx.channel().remoteAddress().toString());
                 }
             }
         });
                 }
             }
         });
index c5b29ee..5e2d82e 100644 (file)
@@ -28,6 +28,8 @@ import java.util.UUID;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.regex.Pattern;
 
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.regex.Pattern;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.ServerSystem;
 import org.iotivity.cloud.base.device.Device;
 import org.iotivity.cloud.base.device.HttpDevice;
 import org.iotivity.cloud.base.ServerSystem;
 import org.iotivity.cloud.base.device.Device;
 import org.iotivity.cloud.base.device.HttpDevice;
@@ -40,7 +42,6 @@ import org.iotivity.cloud.base.protocols.enums.RequestMethod;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.base.server.HttpServer;
 import org.iotivity.cloud.util.Cbor;
 import org.iotivity.cloud.base.protocols.enums.ResponseStatus;
 import org.iotivity.cloud.base.server.HttpServer;
 import org.iotivity.cloud.util.Cbor;
-import org.iotivity.cloud.util.Log;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.type.TypeReference;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.type.TypeReference;
@@ -66,7 +67,7 @@ import io.netty.util.AttributeKey;
  * described in https://tools.ietf.org/html/draft-ietf-core-http-mapping-13.
  */
 public class HCProxyProcessor {
  * described in https://tools.ietf.org/html/draft-ietf-core-http-mapping-13.
  */
 public class HCProxyProcessor {
-
+    private final static Logger Log             = LoggerFactory.getLogger(HCProxyProcessor.class);
     public final static String COAP_FORMAT_TYPE = "application/coap-payload;cf=";
     public final static String APPLICATION_JSON = "application/json";
     public final static String APPLICATION_CBOR = "application/cbor";
     public final static String COAP_FORMAT_TYPE = "application/coap-payload;cf=";
     public final static String APPLICATION_JSON = "application/json";
     public final static String APPLICATION_CBOR = "application/cbor";
@@ -283,7 +284,7 @@ public class HCProxyProcessor {
             if (mContentType.equalsIgnoreCase(APPLICATION_JSON)) {
                 byte[] cborData = null;
                 try { // Cbor: JSON string to Map
             if (mContentType.equalsIgnoreCase(APPLICATION_JSON)) {
                 byte[] cborData = null;
                 try { // Cbor: JSON string to Map
-                    Log.v("Cbor encoding using HashMap.class");
+                    Log.trace("Cbor encoding using HashMap.class");
                     ObjectMapper cborMapper = new ObjectMapper();
                     HashMap<String, Object> cborMap
                     = cborMapper.readValue(content,
                     ObjectMapper cborMapper = new ObjectMapper();
                     HashMap<String, Object> cborMap
                     = cborMapper.readValue(content,
@@ -497,14 +498,14 @@ public class HCProxyProcessor {
                 try { // Cbor: Map to JSON string
 
                     if (getTargetCoapPath().contains(DISCOVER_URI)) {
                 try { // Cbor: Map to JSON string
 
                     if (getTargetCoapPath().contains(DISCOVER_URI)) {
-                        Log.v("Cbor decoding using ArrayList.class");
+                        Log.trace("Cbor decoding using ArrayList.class");
                         ArrayList<Object> cborMap = mStackCborArray
                                 .parsePayloadFromCbor(coapPayload, ArrayList.class);
                         ObjectMapper cborMapper = new ObjectMapper();
                         payloadString = cborMapper.writerWithDefaultPrettyPrinter()
                                 .writeValueAsString(cborMap);
                     } else {
                         ArrayList<Object> cborMap = mStackCborArray
                                 .parsePayloadFromCbor(coapPayload, ArrayList.class);
                         ObjectMapper cborMapper = new ObjectMapper();
                         payloadString = cborMapper.writerWithDefaultPrettyPrinter()
                                 .writeValueAsString(cborMap);
                     } else {
-                        Log.v("Cbor decoding using HashMap.class");
+                        Log.trace("Cbor decoding using HashMap.class");
                         HashMap<String, Object> cborMap = mStackCborMap
                                 .parsePayloadFromCbor(coapPayload, HashMap.class);
                         ObjectMapper cborMapper = new ObjectMapper();
                         HashMap<String, Object> cborMap = mStackCborMap
                                 .parsePayloadFromCbor(coapPayload, HashMap.class);
                         ObjectMapper cborMapper = new ObjectMapper();
index 630eca3..6e10413 100644 (file)
@@ -21,8 +21,6 @@
  */
 package org.iotivity.cloud.base.protocols.http;
 
  */
 package org.iotivity.cloud.base.protocols.http;
 
-import org.iotivity.cloud.util.Log;
-
 import io.netty.channel.ChannelDuplexHandler;
 import io.netty.channel.ChannelHandler.Sharable;
 import io.netty.handler.codec.http.HttpContent;
 import io.netty.channel.ChannelDuplexHandler;
 import io.netty.channel.ChannelHandler.Sharable;
 import io.netty.handler.codec.http.HttpContent;
@@ -34,6 +32,8 @@ import io.netty.handler.codec.http.LastHttpContent;
 import io.netty.util.CharsetUtil;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelPromise;
 import io.netty.util.CharsetUtil;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelPromise;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * This class provides a set of APIs to print out logs
 
 /**
  * This class provides a set of APIs to print out logs
@@ -41,21 +41,20 @@ import io.netty.channel.ChannelPromise;
  */
 @Sharable
 public class HttpLogHandler extends ChannelDuplexHandler {
  */
 @Sharable
 public class HttpLogHandler extends ChannelDuplexHandler {
+    private final static Logger Log             = LoggerFactory.getLogger(HttpLogHandler.class);
 
     @Override
     public void channelActive(ChannelHandlerContext ctx) throws Exception {
 
     @Override
     public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        Log.v(ctx.channel().id().asLongText().substring(26)
-                + " HTTP Connected, Address: "
-                + ctx.channel().remoteAddress().toString());
+        Log.trace("[{}] HTTP Connected, Address: {}", ctx.channel().id().asLongText().substring(26),
+                ctx.channel().remoteAddress().toString());
 
         ctx.fireChannelActive();
     }
 
     @Override
     public void channelInactive(ChannelHandlerContext ctx) throws Exception {
 
         ctx.fireChannelActive();
     }
 
     @Override
     public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        Log.v(ctx.channel().id().asLongText().substring(26)
-                + " HTTP Disconnected, Address: "
-                + ctx.channel().remoteAddress().toString());
+        Log.trace("[{}] HTTP Disconnected, Address: {}", ctx.channel().id().asLongText().substring(26),
+                ctx.channel().remoteAddress().toString());
 
         ctx.fireChannelInactive();
     }
 
         ctx.fireChannelInactive();
     }
@@ -65,7 +64,7 @@ public class HttpLogHandler extends ChannelDuplexHandler {
             throws Exception {
 
         if (!(msg instanceof HttpObject)) {
             throws Exception {
 
         if (!(msg instanceof HttpObject)) {
-            Log.v("Non-HTTP message has been received to the HC proxy:\n"
+            Log.trace("Non-HTTP message has been received to the HC proxy:\n"
                     + msg.toString());
         }
 
                     + msg.toString());
         }
 
@@ -77,12 +76,12 @@ public class HttpLogHandler extends ChannelDuplexHandler {
 
             HttpRequest httpRequest = (HttpRequest) msg;
 
 
             HttpRequest httpRequest = (HttpRequest) msg;
 
-            Log.v(httpRequest.toString());
+            Log.trace(httpRequest.toString());
 
             if (HttpUtil.isTransferEncodingChunked(httpRequest)) {
 
             if (HttpUtil.isTransferEncodingChunked(httpRequest)) {
-                Log.v("BEGINNING OF HTTP CHUNKED CONTENT");
+                Log.trace("BEGINNING OF HTTP CHUNKED CONTENT");
             } else {
             } else {
-                Log.v("BEGINNING OF HTTP CONTENT");
+                Log.trace("BEGINNING OF HTTP CONTENT");
             }
         }
 
             }
         }
 
@@ -97,9 +96,9 @@ public class HttpLogHandler extends ChannelDuplexHandler {
 
             if (content instanceof LastHttpContent) {
 
 
             if (content instanceof LastHttpContent) {
 
-                Log.v(contentStrBuilder.toString());
+                Log.trace(contentStrBuilder.toString());
 
 
-                Log.v("END OF HTTP CONTENT");
+                Log.trace("END OF HTTP CONTENT");
 
                 contentStrBuilder.setLength(0);
             }
 
                 contentStrBuilder.setLength(0);
             }
@@ -113,7 +112,7 @@ public class HttpLogHandler extends ChannelDuplexHandler {
             ChannelPromise promise) {
 
         if (!(msg instanceof HttpObject)) {
             ChannelPromise promise) {
 
         if (!(msg instanceof HttpObject)) {
-            Log.v("Non-HTTP message has been sent from the HC proxy:\n"
+            Log.trace("Non-HTTP message has been sent from the HC proxy:\n"
                     + msg.toString());
         }
 
                     + msg.toString());
         }
 
@@ -125,10 +124,10 @@ public class HttpLogHandler extends ChannelDuplexHandler {
             HttpResponse httpResponse = (HttpResponse) msg;
 
             if (contentStrBuilder.length() > 0) {
             HttpResponse httpResponse = (HttpResponse) msg;
 
             if (contentStrBuilder.length() > 0) {
-                Log.v(httpResponse.toString() + "\n\n"
+                Log.trace(httpResponse.toString() + "\n\n"
                         + contentStrBuilder.toString());
             } else {
                         + contentStrBuilder.toString());
             } else {
-                Log.v(httpResponse.toString());
+                Log.trace(httpResponse.toString());
             }
         }
 
             }
         }
 
index 0fad1f7..41aa021 100644 (file)
@@ -25,23 +25,24 @@ import java.net.InetSocketAddress;
 import java.util.Enumeration;
 import java.util.concurrent.ConcurrentHashMap;
 
 import java.util.Enumeration;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.device.HttpDevice;
 import org.iotivity.cloud.base.protocols.http.HCProxyHandler;
 import org.iotivity.cloud.base.protocols.http.HttpLogHandler;
 import org.iotivity.cloud.base.device.HttpDevice;
 import org.iotivity.cloud.base.protocols.http.HCProxyHandler;
 import org.iotivity.cloud.base.protocols.http.HttpLogHandler;
-import org.iotivity.cloud.util.Log;
 
 import io.netty.channel.ChannelHandler;
 import io.netty.handler.codec.http.HttpRequestDecoder;
 import io.netty.handler.codec.http.HttpResponseEncoder;
 
 public class HttpServer extends Server {
 
 import io.netty.channel.ChannelHandler;
 import io.netty.handler.codec.http.HttpRequestDecoder;
 import io.netty.handler.codec.http.HttpResponseEncoder;
 
 public class HttpServer extends Server {
-
+    private final static Logger Log = LoggerFactory.getLogger(HttpServer.class);
     public static ConcurrentHashMap<String, HttpDevice> httpDeviceMap
     = new ConcurrentHashMap<String, HttpDevice>(); //Key=SID, Value=HttpDevice
 
     public HttpServer(InetSocketAddress inetSocketAddress) {
         super(inetSocketAddress);
     public static ConcurrentHashMap<String, HttpDevice> httpDeviceMap
     = new ConcurrentHashMap<String, HttpDevice>(); //Key=SID, Value=HttpDevice
 
     public HttpServer(InetSocketAddress inetSocketAddress) {
         super(inetSocketAddress);
-        Log.i("HTTP-to-CoAP Proxy is enabled.");
+        Log.info("HTTP-to-CoAP Proxy is enabled.");
 
         Thread sessionTimeoutCheckThread
         = new Thread(new SessionTimeoutCheck());
 
         Thread sessionTimeoutCheckThread
         = new Thread(new SessionTimeoutCheck());
@@ -57,7 +58,7 @@ public class HttpServer extends Server {
         public void run() {
 
             while (true) {
         public void run() {
 
             while (true) {
-                Log.v("HTTP Session registry check is started");
+                Log.trace("HTTP Session registry check is started");
 
                 Enumeration<String> sessionIdList = httpDeviceMap.keys();
 
 
                 Enumeration<String> sessionIdList = httpDeviceMap.keys();
 
@@ -70,7 +71,7 @@ public class HttpServer extends Server {
                     }
                 }
 
                     }
                 }
 
-                Log.v("HTTP Session registry check is ended");
+                Log.trace("HTTP Session registry check is ended");
 
                 try { // Sleep for 1 day
                     Thread.sleep(1000L * 3600L * 24L);
 
                 try { // Sleep for 1 day
                     Thread.sleep(1000L * 3600L * 24L);
index 3272fe8..1a5716d 100644 (file)
@@ -29,8 +29,9 @@ import java.util.List;
 
 import javax.net.ssl.SSLException;
 
 
 import javax.net.ssl.SSLException;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.iotivity.cloud.base.OICConstants;
 import org.iotivity.cloud.base.OICConstants;
-import org.iotivity.cloud.util.Log;
 
 import io.netty.bootstrap.ServerBootstrap;
 import io.netty.channel.ChannelHandler;
 
 import io.netty.bootstrap.ServerBootstrap;
 import io.netty.channel.ChannelHandler;
@@ -46,6 +47,7 @@ import io.netty.handler.ssl.SslContext;
 import io.netty.handler.ssl.SslContextBuilder;
 
 public abstract class Server {
 import io.netty.handler.ssl.SslContextBuilder;
 
 public abstract class Server {
+    Logger            Log                = LoggerFactory.getLogger(Server.class);
 
     EventLoopGroup    acceptorGroup      = new NioEventLoopGroup(1);
 
 
     EventLoopGroup    acceptorGroup      = new NioEventLoopGroup(1);
 
@@ -92,7 +94,7 @@ public abstract class Server {
 
         try {
             if (tlsMode)
 
         try {
             if (tlsMode)
-                Log.i("Server starts with TLS!");
+                Log.info("Server starts with TLS!");
 
             if (tlsMode == true) {
 
 
             if (tlsMode == true) {
 
diff --git a/cloud/stack/src/main/java/org/iotivity/cloud/util/Log.java b/cloud/stack/src/main/java/org/iotivity/cloud/util/Log.java
deleted file mode 100644 (file)
index c054fa3..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- */
-package org.iotivity.cloud.util;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
-import java.net.URI;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-
-import org.apache.log4j.Logger;
-
-import io.netty.channel.Channel;
-
-public class Log {
-
-    public static final int         VERBOSE        = 0;
-    public static final int         DEBUG          = 1;
-    public static final int         INFO           = 2;
-    public static final int         WARNING        = 3;
-    public static final int         ERROR          = 4;
-
-    private static int              logLevel       = VERBOSE;
-
-    private static FileOutputStream fos            = null;
-    private static PrintStream      ps             = null;
-
-    private final static Logger     logger         = Logger
-            .getLogger(Log.class);
-    private static WebsocketLog     websocketpoint = null;
-    private static String           mServerName    = null;
-
-    public static void Init() throws FileNotFoundException {
-        System.setOut(Log.createLoggingProxy(System.out));
-        createfile();
-    }
-
-    public static void InitWebLog(String webLogHost, String serverName) {
-        mServerName = serverName;
-        if (webLogHost != null) {
-            try {
-                websocketpoint = new WebsocketLog(new URI("ws://" + webLogHost));
-                websocketpoint.start();
-            } catch (Exception e) {
-                System.out.println(e.getMessage());
-                websocketpoint = null;
-            }
-        }
-    }
-
-    public static PrintStream createLoggingProxy(
-            final PrintStream realPrintStream) {
-        // TODO Auto-generated method stub
-        return new PrintStream(realPrintStream) {
-            public void print(final String string) {
-                realPrintStream.print(string);
-                logger.fatal(string);
-            }
-        };
-    }
-
-    public static void createfile() throws FileNotFoundException {
-        File dir = new File("..//errLog//");
-        if (!dir.isDirectory()) {
-            dir.mkdirs();
-        }
-        fos = new FileOutputStream("../errLog/[" + getDate() + "] error.log",
-                true);
-        ps = new PrintStream(fos);
-    }
-
-    static public void f(Channel channel, Throwable t) {
-        String log = channel.id().asLongText().substring(26) + " "
-                + t.getMessage();
-        ps.println(getTime() + " " + log);
-        t.printStackTrace(ps);
-        Log.v(log);
-    }
-
-    public static void setLogLevel(int level) {
-        logLevel = level;
-    }
-
-    public static void v(String log) {
-        printLog(VERBOSE, log);
-    }
-
-    public static void d(String log) {
-        printLog(DEBUG, log);
-    }
-
-    public static void i(String log) {
-        printLog(INFO, log);
-    }
-
-    public static void w(String log) {
-        printLog(WARNING, log);
-    }
-
-    public static void e(String log) {
-        printLog(ERROR, log);
-    }
-
-    public static void w(String log, Exception ex) {
-        printLog(WARNING, log);
-        ex.printStackTrace();
-    }
-
-    public static void w(String log, Throwable th) {
-        printLog(WARNING, log);
-        th.printStackTrace();
-    }
-
-    public static void e(String log, Exception ex) {
-        printLog(ERROR, log);
-        ex.printStackTrace();
-    }
-
-    public static void e(String log, Throwable th) {
-        printLog(ERROR, log);
-        th.printStackTrace();
-    }
-
-    private static void printLog(int level, String log) {
-
-        if (logLevel > level)
-            return;
-
-        String format = "";
-        format += getTime();
-        format += " [" + getLogLevelString(level) + "]";
-
-        if (level >= ERROR) {
-            format += " [" + getDetailInfo() + "]";
-        }
-
-        format += " " + log;
-
-        System.out.println(format);
-
-        if (websocketpoint != null && websocketpoint.getUserSession() != null) {
-            websocketpoint.sendMessage("[" + mServerName + "]" + format);
-        }
-    }
-
-    private static String getDetailInfo() {
-
-        String res = "";
-
-        StackTraceElement ste = Thread.currentThread().getStackTrace()[4];
-        String className = ste.getClassName()
-                .substring(ste.getClassName().lastIndexOf(".") + 1);
-
-        res += ste.getFileName() + ", " + className + "." + ste.getMethodName()
-                + "(), line:" + ste.getLineNumber();
-
-        return res;
-    }
-
-    protected static String getTime() {
-        Calendar calendar = Calendar.getInstance();
-        SimpleDateFormat dateFormat = new SimpleDateFormat(
-                "yyyy-MM-dd HH:mm:ss:SSS");
-
-        return dateFormat.format(calendar.getTime());
-    }
-
-    protected static String getDate() {
-        Calendar calendar = Calendar.getInstance();
-        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-        return dateFormat.format(calendar.getTime());
-    }
-
-    private static String getLogLevelString(int level) {
-
-        String res = "";
-
-        if (level == VERBOSE) {
-            res = "V";
-        } else if (level == DEBUG) {
-            res = "D";
-        } else if (level == INFO) {
-            res = "I";
-        } else if (level == WARNING) {
-            res = "W";
-        } else if (level == ERROR) {
-            res = "E";
-        }
-
-        return res;
-    }
-}
diff --git a/cloud/stack/src/main/java/org/iotivity/cloud/util/WebsocketLog.java b/cloud/stack/src/main/java/org/iotivity/cloud/util/WebsocketLog.java
deleted file mode 100644 (file)
index 1e59023..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * //******************************************************************
- * //
- * // Copyright 2016 Samsung Electronics All Rights Reserved.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * //      http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- */
-
-package org.iotivity.cloud.util;
-
-import java.io.IOException;
-import java.net.URI;
-
-import javax.websocket.ClientEndpoint;
-import javax.websocket.CloseReason;
-import javax.websocket.ContainerProvider;
-import javax.websocket.DeploymentException;
-import javax.websocket.OnClose;
-import javax.websocket.OnMessage;
-import javax.websocket.OnOpen;
-import javax.websocket.Session;
-import javax.websocket.WebSocketContainer;
-
-@ClientEndpoint
-public class WebsocketLog extends Thread {
-    private Session            userSession = null;
-    private MessageHandler     messageHandler;
-    private WebSocketContainer container;
-    private URI                endpointURI;
-
-    public WebsocketLog(URI endpointURI)
-            throws DeploymentException, IOException {
-        container = ContainerProvider.getWebSocketContainer();
-        this.endpointURI = endpointURI;
-    }
-
-    @Override
-    public void run() {
-        startConnect();
-    }
-
-    @OnOpen
-    public void onOpen(Session userSession) {
-        this.userSession = userSession;
-    }
-
-    @OnClose
-    public void onClose(Session userSession, CloseReason reason)
-            throws InterruptedException {
-        this.userSession = null;
-        Log.d("Disconnected to websocket for Web Log");
-        startConnect();
-    }
-
-    @OnMessage
-    public void onMessage(String message) {
-        if (this.messageHandler != null)
-            this.messageHandler.handleMessage(message);
-    }
-
-    public void addMessageHandler(MessageHandler msgHandler) {
-        this.messageHandler = msgHandler;
-    }
-
-    public void sendMessage(String message) {
-        this.userSession.getAsyncRemote().sendText(message);
-    }
-
-    public static interface MessageHandler {
-        public void handleMessage(String message);
-    }
-
-    public Session getUserSession() {
-        return userSession;
-    }
-
-    public void startConnect() {
-        int retryCount = 0;
-        do {
-            if (retryCount != 0) {
-                Log.d("retry to Connecting... " + retryCount);
-            }
-
-            try {
-                container.connectToServer(this, endpointURI);
-                Log.d("Success to websocket for Web Log");
-            } catch (DeploymentException | IOException e) {
-                Log.d("Skip Connect to websocket for Web Log");
-            }
-            retryCount++;
-        } while (userSession == null && retryCount < 4);
-    }
-}