--- a/net/common/rpc-service.c
+++ b/net/common/rpc-service.c
@@ -314,7 +314,11 @@ ccnet_start_rpc(CcnetSession *session)
 
 #endif  /* CCNET_SERVER */
 
-    char *path = g_build_filename (session->config_dir, CCNET_SOCKET_NAME, NULL);
+    const char *socket_dir = g_getenv ("SEAFILE_UCI_SOCKET_DIR");
+    if (!socket_dir) {
+        socket_dir = session->config_dir;
+    }
+    char *path = g_build_filename (socket_dir, CCNET_SOCKET_NAME, NULL);
     SearpcNamedPipeServer *server = searpc_create_named_pipe_server_with_threadpool (path, NAMED_PIPE_SERVER_THREAD_POOL_SIZE);
     if (!server) {
         ccnet_warning ("Failed to create named pipe server.\n");
--- a/net/server/ccnet-server.c
+++ b/net/server/ccnet-server.c
@@ -292,10 +292,13 @@ main (int argc, char **argv)
     config_dir = ccnet_expand_path (config_dir);
 
     if (!log_file) {
-        char *logdir = g_build_filename (config_dir, "logs", NULL);
+        char *logdir = g_strdup (g_getenv ("SEAFILE_UCI_LOG_DIR"));
+        if (!logdir) {
+            logdir = g_build_filename (config_dir, "logs", NULL);
+        }
         checkdir_with_mkdir (logdir);
+        log_file = g_build_filename (logdir, "ccnet.log", NULL);
         g_free (logdir);
-        log_file = g_build_filename (config_dir, "logs", "ccnet.log", NULL);
     }
     if (ccnet_log_init (log_file, log_level_str) < 0) {
         fprintf (stderr, "ccnet_log_init error: %s, %s\n", strerror(errno),
