title: How make logger with saving all app logs in Room? (in Runtime)
body: <p>Please, I need help and I broken my head! ((
  How make logger with permanently saving logs when app is running?
  Is it possible to do this without third-party libraries?</p>
  <p><strong>UPDATE:</strong>
  That's what I did</p>
  <pre><code> class AppLogger(private val context: Context, private val db: AppDatabase) : KoinComponent,
      ContextWrapper(context) {
  
      @SuppressLint(&quot;WorldWriteableFiles&quot;, &quot;BinaryOperationInTimber&quot;)
      suspend fun internalSaveFile() {
          withContext(Dispatchers.IO) {
              //-d emulator, -s real device
              val process = Runtime.getRuntime().exec(&quot;logcat -d -v threadtime&quot;)
              val bufferedReader = BufferedReader(
                  InputStreamReader(process.inputStream)
              )
              var line: String? = null
              var counter = 0
  
              while ({ line = bufferedReader.readLine(); line }() != null) {
                  if (line != &quot;--------- beginning of main&quot;) {
  
                      val timeFromLogs = line?.substring(0, 18)
                      var priorityTag = &quot;&quot;
  
                      var t = 0// index to start cutting messages from logs
                      val l = line?.length?.minus(1)
                      for (i in 1..l!!) {
                          if (i &gt; 18) {
                              val q = line?.get(i)
                              if (q == ':') {
                                  t = i
                                  break
                              }
                          }
                      }
                      val messageLog = line?.substring(t + 2)
                      val saveLogs = AppLoggerEntity(
                          counter++, priorityTag, null, null,
                          timeFromLogs, null, null,
                          null, null, message = messageLog
                      )
                      launchSaveInBD(saveLogs)
  
                  }
              }
          }
      }
  
      private fun launchSaveInBD(entity: AppLoggerEntity) {
          GlobalScope.launch {
              db.appLoggerDao().saveLog(entity)
          }
      }
  </code></pre>
  <p>I run it in the Application class, but it only records the logs that appear at the beginning, but do not record anything further.</p>
  <p>My DB - init in Koin</p>
  <pre><code>fun initDatabaseModule(context: Context): Module {
      return module {
          single {
              Room.databaseBuilder(context.applicationContext, AppDatabase::class.java, &quot;app-database&quot;)
                  .fallbackToDestructiveMigration()
                  .build()
          }
  
          factory { get&lt;AppDatabase&gt;().appLoggerDao() }
      }
  }
  </code></pre>
  <p>Initializing in Application() class</p>
  <pre><code>class App : MultiDexApplication() {
      override fun onCreate() {
         super.onCreate()
            initLogger()
            startKoin() {
                //start my loggerModule
      }
      
      private fun initLogger() {
              GlobalScope.launch { 
                  AppLogger(this).internalSaveFile()
              }
          }
      }
  </code></pre>
  <p>I'm also trying start it in MainActivity with inject from koin, but I get similar trouble</p>