Android tools : How to write logs in files.

Android tools : How to write logs in files.

main_banner_for_android.png

Generally, you should use the Log.v(), Log.d(), Log.i(), Log.w(), and Log.e() methods to write logs. You can then view the logs in logcat. The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.

Have some self-respect while you monitor errors

Logs are very importats for every developer. Whith logs we can tracdown bugs and issue in code. We can fet logs easaly when we use app in debug mode in Unit testing. But When tester use application then that time they donwt have android studio. and then we dont get the logs. But we can solve this prob in mini, We can write logs in file and solve issue. For write logs in file we have TxtLogSdk this sdk provides us file logs.

As an Android engineer, every one of you know Logs examination is a period of improvement and we experience it occasionally. Yet, Log Analysis is the fundamental testing thing for code maintainer or Support Engineer. When Any Android item dispatched on the lookout and clients begin utilizing it. At that point genuine situation bugs/issues begin coming and it is the fundamental Job for Support Engineer/Project upkeep architect to break down the Bug/issue with gave set of logs.Integrate this sdk in app and use text logs.

SDK for write application logs into text file.

To get a Git project into your build:

Step 1. Add the JitPack repository to your build file gradle Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency.

dependencies {
        implementation 'com.github.Shekhar23:TxtLogSdk:2.4'
}

Step 3. Initialize sdk

/**
 * This method call is needed only for the initialize sdk
 * @param context : Application context need for file operation.
 * @param isDebugModeOnly : Set it true if you wants log writing for debug mode only.
 */

 TxtLog.sdkInitialize(Application context, boolean isDebugModeOnly);

Step 4. Use sdk with write method

/**
 * This method is used  for write log with TAG
 * @param tag : Tag like class name, or method name.
 * @param message : what you wants to write in file 
 */

TxtLog.write(String tag, String message)

Note : Logfile is created At Location : "/Android/YOUR_PACKAGE_NAME/TxtLogFile.txt"

jitpack.io/#Shekhar23/TxtLogSdk