flutter_log_handler 0.0.2
flutter_log_handler: ^0.0.2 copied to clipboard
Enterprise-grade logging solution for Flutter applications. Provides console logging, file persistence, crash capturing, Dio API interception, retention control, and a built-in professional log viewer UI.
flutter_log_handler #
Enterprise-Grade Logging & Monitoring Framework for Flutter
A production-ready logging solution built specifically for Flutter applications.
Designed for scalable apps, internal admin panels, QA builds, and production monitoring.
๐ฅ Why flutter_log_handler? #
Modern Flutter applications need more than print().
They need:
- Structured logs
- Persistent storage
- Crash tracking
- API monitoring
- Performance visibility
- Internal log viewer
- Controlled retention
- Shareable diagnostics
flutter_log_handler provides all of that in a lightweight, configurable, and extensible architecture.
๐ Core Capabilities #
๐ Structured Logging #
Clean log model with levels, timestamps, routes and stack traces.
๐ File Persistence #
Logs saved locally with configurable directory & file name.
๐ง In-Memory Log Store #
Fast access without reading file every time.
๐ Professional Log Viewer UI #
Built-in log screen with:
- Filtering by level
- Expandable stack traces
- Refresh support
- Share logs
- Clean enterprise UI
๐ฅ Automatic Crash Capture #
Capture:
- Flutter framework errors
- Unhandled runtime exceptions
- Zoned errors
๐ Dio API Interceptor #
Automatic logging of:
- Requests
- Responses
- Slow APIs
- API errors
- Duration tracking
๐งน Retention & Log Limit Control #
- Maximum log count
- Retention days support
- File rotation ready architecture
๐ฏ Ideal For #
- Enterprise Flutter apps
- Production builds
- QA debugging
- Internal monitoring dashboards
- Crash diagnostics
- API performance tracking
- White-label client apps
๐ฆ Installation #
dependencies:
flutter_log_handler: ^0.0.2
flutter pub get
โ๏ธ Quick Setup #
1๏ธโฃ Initialize Logger #
void main() async {
WidgetsFlutterBinding.ensureInitialized();
LogService.init(
const LogConfig(
maxLogs: 1000,
retentionDays: 7,
enableConsoleLog: true,
enableFileLog: true,
fileName: "app_logs.txt",
directoryName: "logs",
),
);
await LogService.to.getLogs();
runApp(const MyApp());
}
## ๐ Sensitive Data Masking
flutter_log_handler automatically masks sensitive fields such as:
- password
- token
- accessToken
- refreshToken
- authorization
- apiKey
You can customize this:
LogConfig(
sensitiveKeys: ["password", "secretKey"],
);
๐ Log Events Anywhere #
LogService.to.logEvent(
message: "User logged in",
level: LogLevel.info,
);
๐ฅ Load Logs Automatically #
await LogService.to.getLogs();
This will:
- Load logs from file (if enabled)
- Sync logs into memory
- Prepare logs for UI display
With Stack Trace #
LogService.to.logEvent(
message: error.toString(),
level: LogLevel.error,
stackTrace: stack.toString(),
);
๐งน Crash Capture Setup #
await CrashWrapper.initialize(
app: const MyApp(),
logService: LogService.to,
);
Automatically captures:
- Flutter framework errors
- Unhandled async errors
- Zone errors
๐ API Monitoring (Dio) #
final dio = Dio();
dio.interceptors.add(
ApiInterceptor(LogService.to),
);
Logs:
- HTTP method
- URL
- Response status
- API duration
- Slow APIs (>2000ms)
- Error stack traces
๐ฅ Professional Log Viewer #
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const MyLogScreen(),
),
);
Features:
- Filter logs by level
- Expand stack traces
- Refresh logs
- Share logs
- Clean enterprise card layout
๐ Configuration Options #
LogConfig(
maxLogs: 500,
retentionDays: 5,
enableConsoleLog: true,
enableFileLog: true,
fileName: "app_logs.txt",
directoryName: "logs",
);
| Parameter | Description |
|---|---|
| maxLogs | Maximum logs stored in memory |
| retentionDays | Auto-delete logs older than X days |
| enableConsoleLog | Print logs in debug console |
| enableFileLog | Persist logs to file |
| fileName | Log file name |
| directoryName | Folder inside app documents |
๐ Storage Location #
ApplicationDocumentsDirectory / directoryName / fileName
Example:
/data/user/0/com.example.app/documents/logs/app_logs.txt
๐ก Architecture Highlights #
- Singleton-based LogService
- Configurable behavior
- Zero dependency injection requirement
- Works with GetX or without it
- Extendable for cloud upload
- Future-ready for log rotation
๐ SEO Keywords #
Flutter logger
Flutter crash logger
Flutter file logger
Flutter monitoring tool
Flutter API interceptor
Flutter production logging
Flutter enterprise logging
๐ Designed for Production #
flutter_log_handler is built for teams that require reliability, observability, and structured monitoring inside Flutter applications.
๐ License #
MIT License
๐จโ๐ป Maintainer #
ASTR Raju
Enterprise Flutter Developer