diff --git a/dap-sdk/core/include/dap_common.h b/dap-sdk/core/include/dap_common.h
index 3b58cda9e5d68d7ae879194037bd8b88d4e60c32..430c7af50758794b0b12d60d3264dfebd2301d71 100755
--- a/dap-sdk/core/include/dap_common.h
+++ b/dap-sdk/core/include/dap_common.h
@@ -381,7 +381,7 @@ DAP_STATIC_INLINE void DAP_AtomicUnlock( dap_spinlock_t *lock )
 extern char *g_sys_dir_path;
 
 //int dap_common_init( const char * a_log_file );
-int dap_common_init( const char *console_title, const char *a_log_file );
+int dap_common_init( const char *console_title, const char *a_log_file, const char *a_log_dirpath );
 int wdap_common_init( const char *console_title, const wchar_t *a_wlog_file);
 
 void dap_common_deinit(void);
diff --git a/dap-sdk/core/src/dap_common.c b/dap-sdk/core/src/dap_common.c
index 800425970092a112cf1d408ccb5a8b2d3a2c36e9..8b202b27106eba69728418a827fbeafd679b1a8f 100755
--- a/dap-sdk/core/src/dap_common.c
+++ b/dap-sdk/core/src/dap_common.c
@@ -140,6 +140,7 @@ char* g_sys_dir_path = NULL;
 
 static char s_last_error[LAST_ERROR_MAX]    = {'\0'},
     s_log_file_path[MAX_PATH]               = {'\0'},
+    s_log_dir_path[MAX_PATH]                = {'\0'},
     s_log_tag_fmt_str[10]                   = {'\0'};
 
 static enum dap_log_level s_dap_log_level = L_DEBUG;
@@ -222,7 +223,7 @@ void dap_set_log_tag_width(size_t a_width) {
  * @param[in] a_log_file
  * @return
  */
-int dap_common_init( const char *a_console_title, const char *a_log_filename ) {
+int dap_common_init( const char *a_console_title, const char *a_log_file_path, const char *a_log_dirpath) {
 
     // init randomer
     srand( (unsigned int)time(NULL) );
@@ -230,15 +231,16 @@ int dap_common_init( const char *a_console_title, const char *a_log_filename ) {
     strncpy( s_log_tag_fmt_str, "[%s]\t",sizeof (s_log_tag_fmt_str));
     for (int i = 0; i < 16; ++i)
             s_ansi_seq_color_len[i] =(unsigned int) strlen(s_ansi_seq_color[i]);
-    if ( a_log_filename ) {
-        s_log_file = fopen( a_log_filename , "a" );
+    if ( a_log_file_path ) {
+        s_log_file = fopen( a_log_file_path , "a" );
         if( s_log_file == NULL)
-            s_log_file = fopen( a_log_filename , "w" );
+            s_log_file = fopen( a_log_file_path , "w" );
         if ( s_log_file == NULL ) {
-            dap_fprintf( stderr, "Can't open log file %s to append\n", a_log_filename );
-            //return -1;   //switch off show log in cosole if file not open
+            dap_fprintf( stderr, "Can't open log file %s to append\n", a_log_file_path );
+            return -1;   //switch off show log in cosole if file not open
         }
-        dap_stpcpy(s_log_file_path, a_log_filename);
+        dap_stpcpy(s_log_dir_path,  a_log_dirpath);
+        dap_stpcpy(s_log_file_path, a_log_file_path);
     }
     pthread_create( &s_log_thread, NULL, s_log_thread_proc, NULL );
     return 0;
@@ -301,6 +303,10 @@ static void *s_log_thread_proc(void *arg) {
                 if(!dap_file_test(s_log_file_path)) {
                     fclose(s_log_file);
                     s_log_file = fopen(s_log_file_path, "a");
+                    if( s_log_file == NULL) {
+                        dap_mkdir_with_parents(s_log_dir_path);
+                        s_log_file = fopen( s_log_file_path , "w" );
+                    }
                 }
             }
             DL_FOREACH_SAFE(s_log_buffer, elem, tmp) {
diff --git a/dap-sdk/core/src/dap_file_utils.c b/dap-sdk/core/src/dap_file_utils.c
index db0b71c5849f498fc4dce44096e27631fffaf066..da36e8b5589d5b02edea9c0658ead0cd7d907251 100755
--- a/dap-sdk/core/src/dap_file_utils.c
+++ b/dap-sdk/core/src/dap_file_utils.c
@@ -156,7 +156,8 @@ int dap_mkdir_with_parents(const char *a_dir_path)
 #ifdef _WIN32
             int result = mkdir(path);
 #else
-            int result = mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+            int result = mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH | S_IWOTH);
+                         chmod(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH | S_IWOTH);
 #endif
             if(result == -1) {
                 errno = ENOTDIR;