lib/src/main/java/com/ibm/mobilefirstplatform/clientsdk/android/logger/api/LogPersister.java
static public void setContext(final Context context) {
        // once setContext is called, we can set up the uncaught exception handler since
        // it will force logging to the file
        if (null == LogPersister.context) {

            // set a custom JUL Handler so we can capture third-party and internal java.util.logging.Logger API calls
            LogManager.getLogManager().getLogger("").addHandler(julHandler);
            java.util.logging.Logger.getLogger("").setLevel(Level.ALL);

            LogPersister.context = context;

            // now that we have a context, let's set the fileLoggerInstance properly unless it was already set by tests
            if (fileLoggerInstance == null || fileLoggerInstance instanceof FileLogger) {
                FileLogger.setContext(context);
                fileLoggerInstance = FileLogger.getInstance();
            }

            SharedPreferences prefs = LogPersister.context.getSharedPreferences (SHARED_PREF_KEY, Context.MODE_PRIVATE);

            // level
            if (null != level) {  // someone called setLevel method before setContext
                setLevelSync(level);  // seems redundant, but we do this to save to SharedPrefs now that we have Context
            } else {  // set it to the SharedPrefs value, or DEFAULT if no value in SharedPrefs yet
                setLevelSync(Logger.LEVEL.fromString(prefs.getString(SHARED_PREF_KEY_level, getLevelDefault().toString())));
            }

            // logFileMaxSize
            if (null != logFileMaxSize) {  // someone called setMaxStoreSize method before setContext
                setMaxLogStoreSize(logFileMaxSize);  // seems redundant, but we do this to save to SharedPrefs now that we have Context
            } else {  // set it to the SharedPrefs value, or DEFAULT if no value in SharedPrefs yet
                setMaxLogStoreSize(prefs.getInt(SHARED_PREF_KEY_logFileMaxSize, DEFAULT_logFileMaxSize));
            }

            // capture
            if (null != capture) {  // someone called setCapture method before setContext
                setCaptureSync(capture);  // seems redundant, but we do this to save to SharedPrefs now that we have Context
            } else {  // set it to the SharedPrefs value, or DEFAULT if no value in SharedPrefs yet
                setCaptureSync(prefs.getBoolean (SHARED_PREF_KEY_logPersistence, DEFAULT_capture));
            }

            uncaughtExceptionHandler = new UncaughtExceptionHandler ();
            Thread.setDefaultUncaughtExceptionHandler (uncaughtExceptionHandler);
        }
    }
static public void setContext(final Context context) {
        // once setContext is called, we can set up the uncaught exception handler since
        // it will force logging to the file
        if (null == LogPersister.context) {

            // set a custom JUL Handler so we can capture third-party and internal java.util.logging.Logger API calls
            LogManager.getLogManager().getLogger("").addHandler(julHandler);
            java.util.logging.Logger.getLogger("").setLevel(Level.ALL);

            LogPersister.context = context;

            // now that we have a context, let's set the fileLoggerInstance properly unless it was already set by tests
            if (fileLoggerInstance == null || fileLoggerInstance instanceof FileLogger) {
                FileLogger.setContext(context);
                fileLoggerInstance = FileLogger.getInstance();
            }

            SharedPreferences prefs = LogPersister.context.getSharedPreferences (SHARED_PREF_KEY, Context.MODE_PRIVATE);

            // level
            if (null != level) {  // someone called setLevel method before setContext
                setLevelSync(level);  // seems redundant, but we do this to save to SharedPrefs now that we have Context
            } else {  // set it to the SharedPrefs value, or DEFAULT if no value in SharedPrefs yet
                setLevelSync(Logger.LEVEL.fromString(prefs.getString(SHARED_PREF_KEY_level, getLevelDefault().toString())));
            }

            // logFileMaxSize
            if (null != logFileMaxSize) {  // someone called setMaxStoreSize method before setContext
                setMaxLogStoreSize(logFileMaxSize);  // seems redundant, but we do this to save to SharedPrefs now that we have Context
            } else {  // set it to the SharedPrefs value, or DEFAULT if no value in SharedPrefs yet
                setMaxLogStoreSize(prefs.getInt(SHARED_PREF_KEY_logFileMaxSize, DEFAULT_logFileMaxSize));
            }

            // capture
            if (null != capture) {  // someone called setCapture method before setContext
                setCaptureSync(capture);  // seems redundant, but we do this to save to SharedPrefs now that we have Context
            } else {  // set it to the SharedPrefs value, or DEFAULT if no value in SharedPrefs yet
                setCaptureSync(prefs.getBoolean (SHARED_PREF_KEY_logPersistence, DEFAULT_capture));
            }

            uncaughtExceptionHandler = new UncaughtExceptionHandler ();
            Thread.setDefaultUncaughtExceptionHandler (uncaughtExceptionHandler);
        }
    }
static public void setContext ( final Context context ) { // once setContext is called, we can set up the uncaught exception handler since // it will force logging to the file if ( null == LogPersister . context ) { // set a custom JUL Handler so we can capture third-party and internal java.util.logging.Logger API calls LogManager . getLogManager ( ) . getLogger ( "" ) . addHandler ( julHandler ) ; java . util . logging . Logger . getLogger ( "" ) . setLevel ( Level . ALL ) ; LogPersister . context = context ; // now that we have a context, let's set the fileLoggerInstance properly unless it was already set by tests if ( fileLoggerInstance == null || fileLoggerInstance instanceof FileLogger ) { FileLogger . setContext ( context ) ; fileLoggerInstance = FileLogger . getInstance ( ) ; } SharedPreferences prefs = LogPersister . context . getSharedPreferences ( SHARED_PREF_KEY , Context . MODE_PRIVATE ) ; // level if ( null != level ) { // someone called setLevel method before setContext setLevelSync ( level ) ; // seems redundant, but we do this to save to SharedPrefs now that we have Context } else { // set it to the SharedPrefs value, or DEFAULT if no value in SharedPrefs yet setLevelSync ( Logger . LEVEL . fromString ( prefs . getString ( SHARED_PREF_KEY_level , getLevelDefault ( ) . toString ( ) ) ) ) ; } // logFileMaxSize if ( null != logFileMaxSize ) { // someone called setMaxStoreSize method before setContext setMaxLogStoreSize ( logFileMaxSize ) ; // seems redundant, but we do this to save to SharedPrefs now that we have Context } else { // set it to the SharedPrefs value, or DEFAULT if no value in SharedPrefs yet setMaxLogStoreSize ( prefs . getInt ( SHARED_PREF_KEY_logFileMaxSize , DEFAULT_logFileMaxSize ) ) ; } // capture if ( null != capture ) { // someone called setCapture method before setContext setCaptureSync ( capture ) ; // seems redundant, but we do this to save to SharedPrefs now that we have Context } else { // set it to the SharedPrefs value, or DEFAULT if no value in SharedPrefs yet setCaptureSync ( prefs . getBoolean ( SHARED_PREF_KEY_logPersistence , DEFAULT_capture ) ) ; } uncaughtExceptionHandler = new UncaughtExceptionHandler ( ) ; Thread . setDefaultUncaughtExceptionHandler ( uncaughtExceptionHandler ) ; } }
Context object must be set in order to use the Logger API.  This is called automatically by BMSClient.

@param context Android Context object
Context object must be set in order to use the Logger API . This is called automatically by BMSClient .