private ILogger SetupLogging() { const string fileOutputTemplate = "{Timestamp:dd-MM-yyyy HH:mm:ss.fff} [{Level}] {Message:lj}{NewLine}{Exception}"; var basePath = AndroidUtils.GetLogsPath(); var loggerConfig = new LoggerConfiguration().MinimumLevel .Verbose(); var logs = new Dictionary <string, string> { //data services { $"{typeof(TaskListDataService).FullName}", "data_tasklist_service_.txt" }, { $"{typeof(TaskDataService).FullName}", "data_task_service_.txt" }, { $"{typeof(UserDataService).FullName}", "data_user_service_.txt" }, { $"{typeof(MiraiNotesDataService).FullName}", "data_main_service_.txt" }, //view models { $"{typeof(AccountDialogViewModel).FullName}", "vm_account_dialog_.txt" }, { $"{typeof(AddSubTaskDialogViewModel).FullName}", "vm_addsubtask_dialog_.txt" }, { $"{typeof(ChangeTaskStatusDialogViewModel).FullName}", "vm_changetaskstatus_dialog_.txt" }, { $"{typeof(DeleteTaskDialogViewModel).FullName}", "vm_deletetask_dialog_.txt" }, { $"{typeof(MoveTaskDialogViewModel).FullName}", "vm_movetask_dialog_.txt" }, { $"{typeof(TaskListsDialogViewModel).FullName}", "vm_tasklists_dialog_.txt" }, { $"{typeof(PasswordDialogViewModel).FullName}", "vm_password_dialog_.txt" }, { $"{typeof(AddEditTaskListDialogViewModel).FullName}", "vm_add_edit_tasklists_dialog_.txt" }, { $"{typeof(TaskMenuOptionsViewModel).FullName}", "vm_taskmenuoptions_dialog_.txt" }, { $"{typeof(TaskDateDialogViewModel).FullName}", "vm_taskdate_dialog_.txt" }, { $"{typeof(DeleteAccountDialogViewModel).FullName}", "vm_deleteaccount_dialog_.txt" }, { $"{typeof(LogoutDialogViewModel).FullName}", "vm_logout_dialog_.txt" }, { $"{typeof(SettingsMainViewModel).FullName}", "vm_settings_main_.txt" }, { $"{typeof(GoogleUserViewModel).FullName}", "vm_google_user_.txt" }, { $"{typeof(LoginViewModel).FullName}", "vm_login_.txt" }, { $"{typeof(MainViewModel).FullName}", "vm_main_.txt" }, { $"{typeof(MenuViewModel).FullName}", "vm_menu_.txt" }, { $"{typeof(NewTaskViewModel).FullName}", "vm_newtask_.txt" }, { $"{typeof(TasksViewModel).FullName}", "vm_tasks_.txt" }, { $"{typeof(DeleteTaskListDialogViewModel).FullName}", "vm_deletetasklist_dialog_.txt" }, { $"{typeof(ManageTaskListsDialogViewModel).FullName}", "vm_managetasklists_dialog_.txt" }, //others { $"{typeof(AuthenticatedHttpClientHandler).FullName}", "auth_http_handler_.txt" }, { $"{typeof(SyncBackgroundTask).FullName}", "bg_sync_.txt" }, { $"{typeof(MarkTaskAsCompletedReceiver.MarkAsCompletedTask).FullName}", "bg_marktaskascompleted_.txt" }, { $"{typeof(GoogleApiService).FullName}", "api_google_service_.txt" }, { $"{typeof(SyncService).FullName}", "sync_service_.txt" }, { $"{typeof(NotificationSchedulerReceiver.NotificationSchedulerTask).FullName}", "bg_notificationreceiver_.txt" }, { $"{typeof(BootBroadcastReceiver.RescheduleNotificationsTask).FullName}", "bg_reschedulenotifications_.txt" }, }; foreach (var kvp in logs) { loggerConfig.WriteTo.Logger(l => l .Filter.ByIncludingOnly(Matching.FromSource(kvp.Key)) .WriteTo.File( Path.Combine(basePath, kvp.Value), rollingInterval: RollingInterval.Day, rollOnFileSizeLimit: true, outputTemplate: fileOutputTemplate)); } //for some reason, .log format doesnt work.. but no problem //i can use .txt or .json Log.Logger = loggerConfig.WriteTo.AndroidLog() //Sets the Tag field. .Enrich.WithProperty(Constants.SourceContextPropertyName, "MiraiSoft") .CreateLogger(); return(Log.Logger); }