Logging to a file on Android

后端 未结 6 550
离开以前
离开以前 2020-12-01 11:09

Is there any way of retrieving log messages from an Android handset.

I\'m building an application which uses the GPS of my HTC Hero. I can run and debug the applicat

6条回答
  •  粉色の甜心
    2020-12-01 11:31

    Log4j or slf4j can also be used as logging frameworks in Android together with logcat. See the project android-logging-log4j. Configuring logging to a (rotating) file(s) is very easy.

     static {
        final LogConfigurator logConfigurator = new LogConfigurator();
    
        logConfigurator.setFileName(Environment.getExternalStorageDirectory() + "myapp.log");
        logConfigurator.setRootLevel(Level.DEBUG);
        // Set log level of a specific logger
        logConfigurator.setLevel("org.apache", Level.ERROR);
        logConfigurator.configure();
    }
    

提交回复
热议问题