in the Android project, a log file needs to be put into the SD card for subsequent debugging bugs.
The specific use is as follows:
1. Download the Open source Framework
http://code.google.com/p/microlog4android/downloads/list Download Microlog4android-1.0.0.jar and microlog.properties files
2, establish the use of logger object
private static final Logger Logger = Loggerfactory.getlogger (mainactivity.class);
3. Initialize the method in the OnCreate method of the first activity of the program
Propertyconfigurator.getconfigurator (this). Configure ();
4. Put the microlog.properties file in the Assets folder
Configure the Microlog.properties file for the following:
Microlog.level=debug
Microlog.appender=logcatappender; Fileappender
Microlog.formatter=patternformatter
microlog.formatter.patternformatter.pattern=%c [%P]%m%T
5, write log records for example
Logger.debug ("Show debug level log information only");
6. Add the right to write SD card in Androidmanifest.xml
<uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>
run the program, and then to the SD card root directory, you can find that there is a microlog.txt file, inside is our log.
7. How to change the path and name of the log file, you need to configure the parameter "Microlog.appender.FileAppender.File" to change the path and name of the log file.
The configuration file is as follows:
Microlog.level=debug
Microlog.appender=fileappender; Logcatappender
Microlog.appender.fileappender.file=mylog.txt
Microlog.formatter=patternformatter
microlog.formatter.patternformatter.pattern=%c [%P]%m%T
This article is from the "No Water Fish" blog, please be sure to keep this source http://javaqun.blog.51cto.com/10687700/1737221
Use "Microlog4" for log storage in Android