I am new to android development.I want to write logs to one file in SD Card.How can i do this using Log4j.What all are the steps to Implement Log4j.I read many atricles.But none of them describing how to configure and implement it.Can anyone please explain how to do this in android in simple words.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- how do I log requests and responses for debugging
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
You should look at
logback
(the next generation of log4j). Use theFileAppender
orRollingFileAppender
.Instructions:
Add
slf4j-api-1.6.6.jar
andlogback-android-1.0.6-2.jar
to your classpath.Create the file
assets/logback.xml
in your project (or use theAndroidManifest.xml
...see example), containing the following configuration:Note: Since the specified path is on SD, make sure to use
WRITE_EXTERNAL_STORAGE
permission. You can instead specify a different path where you already have write permissions.Your Java code, which contains the SLF4J logging calls, now logs all events at or above the
DEBUG
level to the/sdcard/testFile.log
.Example Java:
I got answer to my own edit..
I just changed extention of testFile.log file from .log to .txt in logback.xml configuration file, so I can view file in device also..