1. Download
To begin (note:
The downloaded microlog.propertiesis microlog.properties.txt. Modify the suffix)
2. Create a logger object
Private Static final logger = loggerfactory. getlogger (main. Class );
3. initialize the method in the oncreate method of the activit or service of the program.
Propertyconfigurator. getconfigurator (this). Configure ();
4. Put the microlog. properties file in the assets folder.
Note: The assets folder is the same as the res folder.
Then change the microlog. properties file to the following:
Microlog. Level = debug
Microlog. appender = logcatappender; fileappender
Microlog. formatter = patternformatter
Microlog. formatter. patternformatter. pattern = % C [% P] % m % t
5. Write log records
Logger. debug ("My debug ");
6. In androidmanifest. xml
Add SD card write permission
<Uses-Permission Android: Name = "android. Permission. write_external_storage"/>
After the program is started, you can find a microlog.txt file, which contains the logs we recorded.