{"id":31551341,"url":"https://github.com/betomorrow/react-native-file-logger","last_synced_at":"2025-10-04T18:41:55.831Z","repository":{"id":38850743,"uuid":"279536985","full_name":"BeTomorrow/react-native-file-logger","owner":"BeTomorrow","description":"A simple file-logger for React Native with configurable rolling policy, based on CocoaLumberjack on iOS and Logback on Android.","archived":false,"fork":false,"pushed_at":"2025-08-20T10:47:50.000Z","size":3402,"stargazers_count":140,"open_issues_count":3,"forks_count":31,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-09-23T05:33:08.467Z","etag":null,"topics":["cocoalumberjack","file-logger","logback","logging","react-native"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BeTomorrow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-07-14T09:10:21.000Z","updated_at":"2025-09-12T23:50:32.000Z","dependencies_parsed_at":"2024-06-18T16:46:46.731Z","dependency_job_id":"614b4031-4a1b-4d45-a466-3a1759a88320","html_url":"https://github.com/BeTomorrow/react-native-file-logger","commit_stats":{"total_commits":66,"total_committers":5,"mean_commits":13.2,"dds":"0.48484848484848486","last_synced_commit":"2af1eb6e78405eec8ed29d70d19aaa7d3c408377"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/BeTomorrow/react-native-file-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeTomorrow%2Freact-native-file-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeTomorrow%2Freact-native-file-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeTomorrow%2Freact-native-file-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeTomorrow%2Freact-native-file-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BeTomorrow","download_url":"https://codeload.github.com/BeTomorrow/react-native-file-logger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeTomorrow%2Freact-native-file-logger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278358483,"owners_count":25973946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoalumberjack","file-logger","logback","logging","react-native"],"created_at":"2025-10-04T18:41:51.756Z","updated_at":"2025-10-04T18:41:55.797Z","avatar_url":"https://github.com/BeTomorrow.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React-native-file-logger\n\n_A simple file-logger for React Native with configurable rolling policy, based on CocoaLumberjack on iOS and Logback on Android._\n\n## Features\n\n- **💆‍♂️ Easy to setup**: Just call `FileLogger.configure()` and you're done. All your existing `console.log/debug/...` calls are automatically logged into a file.\n- **🌀 File rolling**: Support for time and size-based file rolling. Max number of files and size-limit can be configured. File rolling can also be disabled.\n- **📬 Email support**: Logging into a file is useless if users cannot send logs back to developers. With react-native-file-logger, file logs can be sent by email without having to rely on another library.\n- **🛠 TypeScript support**: Being written entirely in TypeScript, react-native-file-logger has always up-to-date typings.\n\n## How it works\n\nReact-native-file-logger overrides the default `console` functions to capture log messages. The captured messages are then written to log files using [CocoaLumberjack](https://github.com/CocoaLumberjack/CocoaLumberjack) on iOS and [Logback Android](https://github.com/tony19/logback-android) on Android, with configurable rolling policies for log file management.\n\n## Installation\n\n```sh\nnpm i react-native-file-logger\nnpx pod-install\n```\n\n## Getting started\n\n```\nimport { FileLogger } from \"react-native-file-logger\";\n\nFileLogger.configure();\n```\n\nThis is all you need to add file-logging to your app. All your existing `console` calls will be appended to a log file. `FileLogger.configure()` also takes options to customize the rolling policy, log directory path or log-level. If you don't want to use `console` calls for logging, you can also use the [direct access API](#direct-access-api).\n\n## API\n\n#### FileLogger.configure(options?): Promise\n\nInitialize the file-logger with the specified options. As soon as the returned promise is resolved, all `console` calls are appended to a log file. To ensure that no logs are missing, it is good practice to `await` this call at the launch of your app.\n\n| Option                 | Description                                                                                                                                                                               | Default                                    |\n| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |\n| `logLevel`             | Minimum log level for file output (it won't affect console output)                                                                                                                        | LogLevel.Debug                             |\n| `formatter`            | A function that takes the log level and message and returns the formatted string to write to the log file.                                                                                | Default format: `${now} [${level}] ${msg}` |\n| `captureConsole`       | If `true`, all `console` calls are automatically captured and written to a log file. It can also be changed by calling the `enableConsoleCapture()` and `disableConsoleCapture()` methods | `true`                                     |\n| `dailyRolling`         | If `true`, a new log file is created every day                                                                                                                                            | `true`                                     |\n| `maximumFileSize`      | A new log file is created when current log file exceeds the given size in bytes. `0` to disable                                                                                           | `1024 * 1024` (1MB)                        |\n| `maximumNumberOfFiles` | Maximum number of log files to keep. When a new log file is created, if the total number of files exceeds this limit, the oldest file is deleted. `0` to disable                          | `5`                                        |\n| `logsDirectory`        | Absolute path of directory where log files are stored. If not defined, log files are stored in the cache directory of the app                                                             | `undefined`                                |\n| `logPrefix`            | Optional prefix string to prepend to log file names                                                                                                                                       | `undefined`                                |\n\n#### FileLogger.sendLogFilesByEmail(options?): Promise\n\nSend all log files by email. On iOS, it uses `MFMailComposeViewController` to ensure that the user won't leave the app when sending log files.\n\n| Option     | Description                                                                                                           |\n| ---------- | --------------------------------------------------------------------------------------------------------------------- |\n| `to`       | Email address of the recipient                                                                                        |\n| `subject`  | Email subject                                                                                                         |\n| `body`     | Plain text body message of the email                                                                                  |\n| `compress` | If `true`, log files will be compressed into a single zip file before being attached to the email, default to `false` |\n\n#### FileLogger.enableConsoleCapture()\n\nEnable appending messages from `console` calls to the current log file. It is already enabled by default when calling `FileLogger.configure()`.\n\n#### FileLogger.disableConsoleCapture()\n\nAfter calling this method, `console` calls will no longer be written to the current log file.\n\n#### FileLogger.setLogLevel(logLevel)\n\nChange the minimum log level for file-output. The initial log level can be passed as an option to `FileLogger.configure()`.\n\n#### FileLogger.getLogLevel(): LogLevel\n\nReturn the current log level.\n\n#### FileLogger.getLogFilePaths(): Promise\u003cstring[]\u003e\n\nReturns a promise with the absolute paths to the log files.\n\n#### FileLogger.deleteLogFiles(): Promise\n\nRemove all log files. Next `console` calls will be appended to a new empty log file.\n\n## Direct access API\n\nIf you don't want to use `console` calls for file-logging, you can directly use the following methods to directly write messages to the log file. It is encouraged to wrap these calls with your own logger API.\n\n### FileLogger.debug(msg)\n\nShortcut for `FileLogger.write(LogLevel.Debug, msg)`.\n\n### FileLogger.info(msg)\n\nShortcut for `FileLogger.write(LogLevel.Info, msg)`.\n\n### FileLogger.warn(msg)\n\nShortcut for `FileLogger.write(LogLevel.Warning, msg)`.\n\n### FileLogger.error(msg)\n\nShortcut for `FileLogger.write(LogLevel.Error, msg)`.\n\n### FileLogger.write(level, msg)\n\nAppend the given message to the log file with the specified log level. The message will be formatted with the `formatter` function specified during the `FileLogger.configure()` call.\n\n## Troubleshooting\n\n### Release build give empty files\n\nIf you are using the `console` logger api, please check that you do NOT strip logging from your release build with custom transformers in your `babel.config.js` like [babel-plugin-transform-remove-console](https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-remove-console)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetomorrow%2Freact-native-file-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbetomorrow%2Freact-native-file-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetomorrow%2Freact-native-file-logger/lists"}