I have a project where I am implementing an alternative logging backend. My design is modular so there could be multiple logging backends. Each backend is initialized with a pointer to the appropriate backend context. Unfortunately the nrf_log_backend_serial_put function does not properly pass the context when setting up the fprintf_ctx structure.
The fix is quite simple:
nrf_fprintf_ctx_t fprintf_ctx = {
.p_io_buffer = (char *)p_buffer,
.io_buffer_size = length,
.io_buffer_cnt = 0,
.auto_flush = false,
.p_user_ctx = p_backend->p_ctx, //this line change from NULL to p_backend->p_ctx
.fwrite = tx_func
}