# Enabling Logcat in Custom Android Roms

Author
Michael
Published
2013, Feb 19, 11:32 pm
Category
CodingAndroid
Tags

Evidently, some custom ROMs come with Logcat disabled by default. The manner in which it is disabled varies. Here is what worked for me.

(This article assumes you have rooted your device, as well as adb installed and configured correctly, and a basic knowledge of its use)

I recently installed a ROM without logcat enabled. When attempting to access logcat through adb I received the message:

Error : Unable to open log device '/dev/log/main': No such file or directory

To correct the issue I did the following:

### Mount the /system partition as writeable.

We can't get anything done without accessing the /system partition. Thus we must ensure it is mounted as writeable.

$adb shell$ su
# mount

This should output a list containing information about your mounted partitions. You should look for the line where the second (space seperated item) is "/system". The format of the line should be:

partition-name mount-point filesystem-type mount-condition

In our case the mount point is /system. If the mount condition is rw (read / write) you are good to go. If, on the other hand, it is ro (read only) you must do the following:

# mount -o remount,rw -t filesystem-type partition-name mount-point

### Load the logger kernel module.

First you need to locate the logger kernel module. It should be a file named logger.ko located in a folder called modules, somewhere in your /system folder. Try these locations:

/system/lib/modules/logger.ko
/system/modules/logger.ko

This module must be loaded before logcat will work. In order to load it we must create a file in our init.d folder which should be located in your /system folder. On my system the location was:

/system/etc/init.d/

In this directory files are executed as the device boots in the order of the numbers which prepends their file-names.

At this point we should create a file on our computer named something like:

99logcat

This file is to be a script insuring the logger module gets loaded. It should contain text similar to:

#!/system/bin/sh
insmod /system/modules/logger.ko

The path after the #! should reflect the directory containing the insmod executable. The path after insmod should reflect the location of logger.ko.

Once we've saved that, we should push that file to the correct location on the device with:

Alternatively you can create this file on your devices with a root text editor. Now all we need to do is reboot.

### Other potential solutions

Here are some of the things which didn't work for me:

• Running the command enlog from the adb shell
• Dialling *#*#2846579#*#* to access the service menu
• Using Semaphore Manager (or other applicable kernel tools)