Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Help with Android Logging

Sam
2011-07-21
2013-04-26
  • Sam
    Sam
    2011-07-21

    Hello All,
    I am trying to implement logging on my android project. I am trying the following:

    public class MainActivity extends Activity {
        /** Called when the activity is first created. */
      private static Logger log;
      private FileAppender appender;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            log = LoggerFactory.getLogger();
            PropertyConfigurator.getConfigurator(this).configure();
            this.appender = new FileAppender();
            PatternFormatter patternFormatter=new PatternFormatter();
            patternFormatter.setPattern("%d{DATE}  %m");
            this.appender.setFileName( "/sdcard/pra/prv_a.txt");
            this.appender.setFormatter(patternFormatter);
            log.setLevel(Level.DEBUG);
            log.addAppender(this.appender);
            log.debug("Testing");
            setContentView(R.layout.main);
        }
    }

    But when i check on the /sdcard/pra folder i do not see the file being created. Am i missing out on something? Kindly help me with this.

    <b>Thanking you,
    Regards,
    S.A.Norton Stanley</b>