The log buffer on Xiaomi smartphones is a critical but often overlooked component of the system, which is responsible for storing error logs, debugging information and system events that help diagnose crashes, optimize performance, or even recover data after critical errors. However, standard MIUI settings are far from optimal: too small a buffer leads to the loss of important logs, and too large a buffer leads to unnecessary memory consumption and slowdown of the device.
In this article, we will look at how to choose a log buffer size for different use cases (from everyday use to custom firmware debugging), how to configure it through an engineering menu or ADB, and what hidden MIUI parameters affect logging system events.
What is a magazine buffer and why is it needed for Xiaomi?
A log buffer is a dedicated RAM area (RAM) where the system temporarily stores the kernel, drivers, and application logs. Unlike persistent logs that are written to disk (e.g., /data/log), the buffer operates in real time and is cyclically overwritten when overflowed.
- π Failure diagnosis: When a smartphone suddenly shuts down or freezes, it is the log buffer that contains the last records of the system state before the incident.
- π οΈ Firmware debugging: Custom developers ROM use buffer logs to find bugs in the kernel or drivers.
- β‘ Performance optimization: Log analysis helps identify bottlenecks in the processor, memory, or network modules.
- π± Data recovery: In some cases, fragments of lost information can be extracted from the buffer (for example, after resetting settings).
On Xiaomi smartphones, the magazine buffer is set to the minimum size (usually 256-512 KB), which is enough for basic diagnostics, but not enough for deep debugging. Moreover, in MIUI, some logs are deliberately limited for security and privacy reasons, which makes analysis difficult for power users.
β οΈ Warning: Increasing the size of the log buffer beyond reasonable limits (over 4 MB) can cause system slowdowns, especially on devices with 4 GB of RAM or less. On the Redmi Note 9β11 series and POCO X3 models, this manifests as slowdowns when multitasking.
Standard magazine buffer sizes for different tasks
The best buffer size depends on what you use it for, and the table below is recommended for different scenarios:
| Use case scenario | Recommended buffer size | Examples of devices | Features |
|---|---|---|---|
| Everyday use | 512 KB - 1 MB | Redmi 10, POCO M4 Pro | Enough for basic diagnosis without loss of performance. |
| Custom firmware debugging | 2-4 MB | Xiaomi 12T, POCO F4 GT | Allows you to record long-term logs of the kernel and modules. |
| Application development | 1-2 MB | Black Shark 5, Xiaomi Mix 4 | You need to track logcat and dmesg logs. |
| Recovery from disruption | 4-8MB | Xiaomi 13 Ultra, POCO F5 | Maximum size for saving logs before a critical error. |
For most users, the best trade-off is 1MB. Itβs enough to capture critical events (such as camera driver errors or 5G module errors), but it doesnβt overload the system. If youβre developing or testing firmware, you can increase the buffer to 4MB, but only on devices with 6GB of RAM and above.
How to change the size of the magazine buffer on Xiaomi
The log buffer can be configured in two ways: through the engineering menu (for official firmware MIUI) or using the ADB- commands (a universal method for any firmware, including custom ones).
Method 1: Through the Engineering Menu (MIUI)
This method works on most Xiaomi devices with official firmware, but requires activation of the developer mode:
- Go to Settings β About Phone and 7 times click on the MIUI Version to unlock the Developer Mode.
- Return to Settings β Additional β For developers and enable the option to debug over USB.
- Open the Phone app and enter the code ##4636## (some models may not work β see the alternative below).
- In the menu that appears, select Phone Information β Log settings (or Logging settings).
- Find the Log buffer size and set the desired value (in bytes, for example, 1048576 for 1 MB).
If ##4636### doesnβt work, try an alternative way through the MTK Engineering Mode app (for MediaTek devices) or Qualcomm Service Menu (for Snapdragon), which can be found on the 4PDA forum in your modelβs themes.
What to do if the engineering menu is not available?
Method 2: A Universal Method (ADB)
To change the size of the buffer through ADB, follow the following steps:
- Connect your smartphone to your PC and make sure that USB debugging is enabled.
- Open the command prompt (Windows) or terminal (Linux/macOS) and type:
adb shell
su
echo 2097152 > /proc/sys/kernel/printk_ratelimit_burst
echo 1048576 > /sys/module/printk/parameters/console_suspendHere:
- 2097152 β buffer size in bytes (2 MB).
- console_suspend is a parameter responsible for logging during sleep of the device.
To save the changes after the reboot, you need to edit the file /system/build.prop (root rights required) and add lines:
persist.logd.size=2M
persist.logd.filter=allβ οΈ Warning: Incorrect editing of build.prop can lead to bootloop (locked device turn on).Before making changes, back up the file!
Install ADB-PC drivers|
Enable debugging over USB on your phone |
Download the Android SDK Tools| platform
Check the connection with the adb devices | command
Create a backup of current settings (adb backup)
-->
Optimization of the magazine buffer for custom firmware
On custom firmware (e.g. LineageOS, ArrowOS or Pixel Experience), the approach to configuring the log buffer is different from MIUI. Logging is often more flexible, but requires manual configuration.
- π No restrictions MIUI: Custom firmware does not block access to full kernel logs (dmesg) and system events.
- π§ Magisk module support: You can install Logcat Extender or Kernel Logger modules for advanced logging.
- βοΈ Init.d configuration: Scripts in the /system/etc/init.d folder allow you to automate the change in buffer parameters when booting.
An example of a script for init.d that increases the buffer to 4 MB and includes logging all events:
#!/system/bin/sh
echo 4194304 > /sys/module/printk/parameters/console_suspend
echo 8 > /proc/sys/kernel/printk
chmod 666 /dev/log/main
chmod 666 /dev/log/systemTo install the script:
- Create a 99-logbuffer file in the /system/etc/init.d folder.
- Give it execution rights: chmod 755 /system/etc/init.d/99-logbuffer.
- Reset the device.
On firmware with support for Magisk, you can use the LogEnabler module, which automatically applies the optimal buffer settings and saves the logs to /sdcard/logs.
π‘
If after installing custom firmware smartphone began to slow down, check the size of the log buffer command cat /proc/sys/kernel/printk. value above 7 may indicate excessive logging.
How to read and save logs from the journal buffer
Even after you set up the buffer, the contents are useless unless you know how to extract and analyze the logs.
| Team team. | Description | Example of inference |
|---|---|---|
| dmesg | Shows the kernel logs (drivers, hardware events). | [ 123.456789] mmc0: error -110 whilst initialising SD card |
| logcat | Logs of applications and system services. | E/AndroidRuntime(1234): FATAL EXCEPTION: main |
| cat /proc/kmsg | Streaming reading of kernel logs in real time. | <6>[12345.678901] thermal_engine: Mitigation: CPU0 |
| adb logcat -d > log.txt | Save logs to a file on a PC. | log.txt file with full history of events. |
To save logs to a device without a PC, you can use applications:
- π± Logcat Extreme allows logs to be filtered by importance level (ERROR, WARNING, INFO).
- π± MatLog β supports color markup and log search.
- π± aLogcat is open source, no ads.
If you need to analyze logs after a crash (such as bootloop), use fastboot mode:
fastboot boot twrp.img
adb pull /proc/last_kmsgThe last_kmsg file contains the last kernel recordings before an emergency shutdown.
Common mistakes and their solutions
When you use a magazine buffer, you often have typical problems, and here are the most common ones and how to fix them:
- π« Logcat does not show logs: check if debugging is enabled with USB and if there are no filters in the application. Also make sure the buffer is not crowded (clear it with logcat -c command).
- π "Legs break after reboot": this is normal buffer behavior. To keep logs constant, use logcat -f /sdcard/log.txt.
- β οΈ "Device brakes after buffer enlargement": Reduce the size to 1 MB or turn off logging of unnecessary modules (e.g. net or battery).
- π "No access to /proc/kmsg": some firmware requires root rights. Try using su -c "cat /proc/kmsg."
If after changing the buffer, the smartphone stopped booting, try resetting the settings via fastboot:
fastboot erase cache
fastboot rebootIn extreme cases, you will have to reflash the device through the Mi Flash Tool.
π‘
Before any manipulation of the log buffer, back up your current logs with the adb bugreport command, which will help you recover information if something goes wrong.
Security and privacy: what is stored in the buffer
The log buffer contains not only technical information, but also data that may pose a risk to privacy:
- π Location: Logs GPS and network modules can reveal your location.
- π Phone numbers: Outbound/inbound calls are stored in the phone logs (ril).
- π URL- Addresses: browsers and applications can record pages visited.
- π Authorization Tokens: Some applications log temporary access keys.
To minimize the risks:
- Clean the buffer regularly: logcat -c or dmesg -c.
- Use the filters: logcat | grep -v "password\|token\|location".
- Disable logging of sensitive modules (such as gps or telephony).
On MIUI firmware, some of the logs are encrypted, but this does not guarantee full protection. If you sell or transfer a device, make a full reset (fastboot erase userdata), because even after a normal reset via the menu, some of the logs can remain in memory.