Skip to content

Instantly share code, notes, and snippets.

@lidemin
Created May 16, 2014 09:05
Show Gist options
  • Save lidemin/09110aacb22a4f162fd6 to your computer and use it in GitHub Desktop.
Save lidemin/09110aacb22a4f162fd6 to your computer and use it in GitHub Desktop.
ConfigureLog4J
/**
* This class is used for configure Log4J for Android.
* Before configure log4j make sure your project has already included
* 'log4j' and 'de.mindpipe.android:android-logging-log4j:1.0.3'.
*
* Then in you app onCreate() function you can use this class to configure.
*
* ConfigureLog4J.configure();
*
* After this you can use :
* public final Logger _logger = Logger.getLogger(TAG);
* as logger
*/
public class ConfigureLog4J {
public static void configure() {
final LogConfigurator logConfigurator = new LogConfigurator();
logConfigurator.setUseFileAppender(false);
// logConfigurator.setFileName(Environment.getExternalStorageDirectory() + File.separator + "myapp.log");
logConfigurator.setRootLevel(Config.DEBUG_LEVEL);
// Set log level of a specific logger
logConfigurator.setLevel("org.apache", Config.DEBUG_LEVEL);
logConfigurator.configure();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment