LogKit is a lightweight, powerful, and production-ready Flutter logging package that extends the popular logger package.
It supports console logging, Hive-based persistent storage, and log exporting—on both native and web platforms.
✅ Console Logging with the logger package
✅ Persistent Log Storage using Hive (Filesystem on native, IndexedDB on Web)
✅ Auto-delete logs from previous day to prevent bloat
✅ Export logs to a .log file (native) or download as .log (web)
✅ Supports all major log levels: debug, info, warning, error, fatal
✅ Compatible with Android, iOS, Windows, macOS, Linux, and Web (WASM)
If you're upgrading from LogKit 1.x, please check the Migration Guide for breaking changes in version 2.0.0.
In your pubspec.yaml:
dependencies:
logkit: ^2.0.1 # Use the latest version
hive: ^2.2.3
path_provider: ^2.1.5Then run:
flutter pub getimport 'package:logkit/logkit.dart';Call initialize() before logging anything:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final logkit = LogKit();
await logkit.initialize(); // Required for Hive setup
runApp(const MyApp());
}logkit.log("This is an info message"); // Default level: info
logkit.log("Debugging details...", level: Level.debug);
logkit.log("Warning message!", level: Level.warning);
logkit.log("Something went wrong!", level: Level.error);String path = await logkit.exportLogsToFile();
print("Logs exported to: $path");await logkit.exportLogsToWebDownload(); // Triggers browser downloadList<String> logs = logkit.getAllLogs();
logs.forEach(print);import 'package:flutter/material.dart';
import 'package:logkit/logkit.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final logkit = LogKit();
await logkit.initialize();
logkit.log("App started!");
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text("LogKit Example")),
body: Center(
child: ElevatedButton(
onPressed: () {
final logkit = LogKit();
logkit.log("Button clicked!", level: Level.info);
},
child: const Text("Log Message"),
),
),
),
);
}
}We welcome contributions!
- ✅ Report bugs via GitHub issues
- ✅ Submit PRs for improvements
- ✅ Help us improve support for new platforms or features
This project is licensed under the MIT License. See LICENSE for full details.
🚀 Start logging like a pro with LogKit! 🔥 Lightweight. Flexible. Cross-platform.
