Logging to file - device freezes

I'm in the project in which we are trying to implement logging to file functionality to NRF5340 chip. 

Following lines were added to config.proj file:

# experimental logging functionality to file
CONFIG_LOG=y
CONFIG_LOG_BACKEND_FS=y
CONFIG_LOG_DEFAULT_LEVEL=4
CONFIG_LOG_BUFFER_SIZE=1024
CONFIG_LOG_BACKEND_FS_FILE_SIZE=4096
CONFIG_LOG_BACKEND_FS_FILES_LIMIT=10
CONFIG_LOG_BACKEND_FS_DIR="/lfs"



# experimental SHELL settings with larger buffer for 2048 bytes
#CONFIG_SHELL_BACKEND_DUMMY_BUF_SIZE is a parameter which sets a buffer size when displaying a shell trough bluetooth. This parameter has no effect on shell through segger.
CONFIG_SHELL_BACKEND_DUMMY_BUF_SIZE=2048
#CONFIG_MCUMGR_BUF_SIZE is a parameter which should be larger by at least 32 bytes than CONFIG_SHELL_BACKEND_DUMMY_BUF_SIZE. Here it is larger by 128 bytes.
CONFIG_MCUMGR_BUF_SIZE=2176
Please note that second block was also added because on the Nordic app, output from Bluetooth console was clipped. This part was added to extend the buffer to display everything.
Problem is as follows:
1. When I make a clean build, and try to read images trought the Nordic android app, device goes in to the timeout and freezes
2. When I disable 
      CONFIG_SHELL_BACKEND_DUMMY_BUF_SIZE=2048
      CONFIG_MCUMGR_BUF_SIZE=2176
and launch a build (not a pristine one- generic build) device does not freeze 
3.When I reenable above lines and make a generic build - device does not freeze 
Or
When I disable logging to file
      CONFIG_LOG_BACKEND_FS=y
      CONFIG_LOG_DEFAULT_LEVEL=4
      CONFIG_LOG_BUFFER_SIZE=1024
      CONFIG_LOG_BACKEND_FS_FILE_SIZE=4096
      CONFIG_LOG_BACKEND_FS_FILES_LIMIT=10
      CONFIG_LOG_BACKEND_FS_DIR="/lfs"
and keep
      CONFIG_SHELL_BACKEND_DUMMY_BUF_SIZE=2048
      CONFIG_MCUMGR_BUF_SIZE=2176
device works and does not freeze
Or (important)
When device is frozen and I connect segger RTT on the PC (F2 key), device flushes log on the screen and resumes operation. 
Could you tell me how to resolve above problem or how to correctly configure logging to file?
 
Related