How to Truncate Macrodroid's System/User Log files

mdman2021

New member
Does anyone know how to truncate both the Macrodroid User Log file -and- the Macrodroid System Log file? Don't these files grow unbounded (size is limitless)? It would be nice to keep the last several days of log entries.

If there is no built-in Macrodroid log truncation then I suspect I might be able to write a Macrodroid shell script (see below) to save the last 500 lines, but I don't know where the Macrodroid log files are or what the filenames are. In short, I guess all I need to know is where the Macrodroid log files are (the PATH or directory) and what the filenames are. I will run this shell script like once every 2 months.

The following is the Macrodroid (abbreviated MD) shell script I intend to use to truncate the Macrodroid log files :

# Set following variable to the FULL directory PATH containing the MD User Log file :
MD_User_Log_Path=/path_to_MD_User_Log_file
# Set following variable to the MD User Log file name :
MD_User_Log_File=MD_User_Log_file

cd $MD_User_Log_Path
# Save current User Log file for later reference : (Will be overwritten next time this routine is ran)
cp -f $MD_User_Log_File $MD_User_Log_File.saved
# Copy last 500 lines of saved User Log back into current User Log file :
cat $MD_User_Log_File.saved | tail 500 > $MD_User_Log_File

# Set following variable to the FULL directory PATH containing the MD System Log file :
MD_System_Log_Path=/path_to_MD_System_Log_file
# Set following variable to the MD System Log file name :
MD_System_Log_File=MD_System_Log_file

cd $MD_System_Log_Path
# Save current System Log file for later reference : (Will be overwritten next time this routine is ran)
cp -f $MD_System_Log_File $MD_System_Log_File.saved
# Copy last 500 lines of saved System Log back into current System Log file :
cat $MD_System_Log_File.saved | tail 500 > $MD_System_Log_File


If the concept of my script is sound, then all I need to do is replace the bold-italicized text (in the following shell script variables) with the actual values :

MD_User_Log_Path=/path_to_MD_User_Log_file
MD_User_Log_File=MD_User_Log_file

MD_System_Log_Path=/path_to_MD_System_Log_file
MD_System_Log_File=MD_System_Log_file


Thanks in advance!
 

Jacob L

Moderator
You can use the share action and put it someplace you can find it and then use yur shell to truncate it. There is no built in feature yet
 

mdman2021

New member
You can use the share action and put it someplace you can find it and then use yur shell to truncate it. There is no built in feature yet
Jacob, Actually there is a Macrodroid built-in Action called "Clear Log". When configuring this Action you are prompted to specify either the Macrodroid "User Log" or the Macrodroid "System Log".

My desire is to first make a copy of the log before clearing it (emptying it) but I do not know where (what directory/folder) these Macrodroid logs are located on my phone, nor do I know what the filenames are called.
 

mdman2021

New member
More info on saving the Macrodroid logs (User Log -AND- System Log).

Thanks to Jacob for suggesting using the share feature. Here is what I have found so far...

Too bad there doesn't seem to be a way to backup the MD logs AUTOMATICALLY like once every two months. It also doesn't appear that the MD logs are kept in file format which can be easily viewed with a text viewer/editor. I suspect they are kept in some kind of MD proprietary format. Alas, the following steps are manual.

To MANUALLY backup the MD User Log :
1) Go to the MD home menu -and- Tap on the button labeled "User Log"
2) Tap the "share" symbol (top right of screen) then select your email app
3) A "Compose" email screen will open with the User Log attached as a "txt" document
4) Send the email to yourself
5) Login to your email and save the attached "txt" file

To MANUALLY backup the MD System Log :
1) Go to the MD home menu -and- Tap on the button labeled "System Log"
2) Tap on the 3 vertical dots menu button (top right of screen)
3) Select "Share log" from the drop-down list then select your email app
4) A "Compose" email screen will open with the System Log attached as a "txt" document
5) Send the email to yourself
6) Login to your email and save the attached "txt" file


After backing-up these MD log files, they can now be "cleared" (emptied) :

To clear/empty the MD User Log :
1) Go to the MD home menu -and- Tap on the button labeled "User Log"
2) Tap on the 3 vertical dots menu button (top right of screen)
3) Select "Clear log" from the drop-down list

To clear/empty the MD System Log :
1) Go to the MD home menu -and- Tap on the button labeled "System Log"
2) Tap on the 3 vertical dots menu button (top right of screen)
3) Select "Clear log" from the drop-down list
 

Jacob L

Moderator
You can use total commander and share the log to total commander. Then choose a folder to store it. Then you can use the shell to perform the actions
 

tanutanu

Well-known member
More info on saving the Macrodroid logs (User Log -AND- System Log).

Thanks to Jacob for suggesting using the share feature. Here is what I have found so far...

Too bad there doesn't seem to be a way to backup the MD logs AUTOMATICALLY like once every two months. It also doesn't appear that the MD logs are kept in file format which can be easily viewed with a text viewer/editor. I suspect they are kept in some kind of MD proprietary format. Alas, the following steps are manual.

To MANUALLY backup the MD User Log :
1) Go to the MD home menu -and- Tap on the button labeled "User Log"
2) Tap the "share" symbol (top right of screen) then select your email app
3) A "Compose" email screen will open with the User Log attached as a "txt" document
4) Send the email to yourself
5) Login to your email and save the attached "txt" file

To MANUALLY backup the MD System Log :
1) Go to the MD home menu -and- Tap on the button labeled "System Log"
2) Tap on the 3 vertical dots menu button (top right of screen)
3) Select "Share log" from the drop-down list then select your email app
4) A "Compose" email screen will open with the System Log attached as a "txt" document
5) Send the email to yourself
6) Login to your email and save the attached "txt" file


After backing-up these MD log files, they can now be "cleared" (emptied) :

To clear/empty the MD User Log :
1) Go to the MD home menu -and- Tap on the button labeled "User Log"
2) Tap on the 3 vertical dots menu button (top right of screen)
3) Select "Clear log" from the drop-down list

To clear/empty the MD System Log :
1) Go to the MD home menu -and- Tap on the button labeled "System Log"
2) Tap on the 3 vertical dots menu button (top right of screen)
3) Select "Clear log" from the drop-down list
The log files are exported as MacroDroidLog.txt and MacroDroidUserLog.txt file just when you tapped share menu on each log view. These are located in the directory, /storage/emulated/0/Android/data/com.arlosoft.macrodroid/files/ .
So you might need to copy and rename to another, but doesn't need to send as an email. Below Android 10 device it can open directly, and even though 11+ it is possible to open it on any apps which accept text such as clipboard as well.
The directory seems to be hidden on Android 11+ devices unfortunately.

@mdman2021, I agree with you and hope it could be exported by action as same as .mdr export:) but the scripting is a little annoying. I don't think it is suitable for everyone.
 
Last edited:

FrameXX

Well-known member
MacroDroid system log is stored in:
/data/data/com.arlosoft.macrodroid/files/macrodroid_event_log_2

MacroDroid user log is stored in:
/data/data/com.arlosoft.macrodroid/files/MacroDroidUserLog.txt

If you are rooted you could automatically copy these files into your internal storage, but if you are not, you don't have direct access to them.
 

tanutanu

Well-known member
MacroDroid system log is stored in:
/data/data/com.arlosoft.macrodroid/files/macrodroid_event_log_2

MacroDroid user log is stored in:
/data/data/com.arlosoft.macrodroid/files/MacroDroidUserLog.txt

If you are rooted you could automatically copy these files into your internal storage, but if you are not, you don't have direct access to them.
mmm, different file name :oops: seems to depend on Android versions :unsure:
 

FrameXX

Well-known member
Just do it now :unsure: 🙃🤔

Ohh. So it's availible even in internal storage! That's even better! I was mentioning it's existence in root storage of apps. For this storage I have same file names as you have. And this is even better because @mdman2021 can copy this files without root.

The path for system log is:
/storage/emulated/0/Android/data/com.arlosoft.macrodroid/files/MacroDroidLog.txt

Or:
/storage/emulated/0/Android/data/com.arlosoft.macrodroid/files/SystemLog.txt

The path for user log is:
/storage/emulated/0/Android/data/com.arlosoft.macrodroid/files/MacroDroidUserLog.txt
 

tanutanu

Well-known member
Ohh. So it's availible even in internal storage! That's even better! I was mentioning it's existence in root storage of apps. For this storage I have same file names as you have. And this is even better because @mdman2021 can copy this files without root.

The path for system log is:
/storage/emulated/0/Android/data/com.arlosoft.macrodroid/files/MacroDroidLog.txt

Or:
/storage/emulated/0/Android/data/com.arlosoft.macrodroid/files/SystemLog.txt

The path for user log is:
/storage/emulated/0/Android/data/com.arlosoft.macrodroid/files/MacroDroidUserLog.txt
Yeahhh, I guess it might be the last verson to export there because 5.18.1 should be based on SDK API Lv29. Once I get a next (current for you), it might be changed even though Android 10 device :unsure:
My 11, Xiaomi mobile doesn't allow me to reach the app directory😢
 
Top