Instead of logging to the disk directly, the server could create a memory buffer, and write log messages (also) there.
This could be configured also on a log level/component basis, for example writing everything up to warning to the disk, and everything up to debug to this memory buffer.
When the buffer gets full it is written to the disk. It is also written out when the server shuts down normally, or when it crashes (in the core dump/crash handling logic). This ensures that no log messages are lost (only delayed) unless there's a power/hardware issue.
This feature would be useful for example for PXC galera/wsrep replication, where without debug logging we don't get useful logs in case of an error, but with debug logs enabled we add a significant IO overhead, and also add a large amount of clutter to the logs.