An IntelliJ IDEA plugin that automatically inserts and removes logging statements in your Java and Kotlin code. Save time and improve debugging efficiency by adding comprehensive logging with just a few clicks.
- Automatic Log Insertion: Insert logging statements into all methods of a class with a single action
- Automatic Log Removal: Remove all inserted logs from a class quickly and cleanly
- Multi-Language Support: Works with both Java and Kotlin files
- Multiple Logging Frameworks:
- System.out.println (default)
- Android Log (
Log.dfromandroid.util.Log) - Timber (Android logging library)
- Napier (Kotlin Multiplatform logging library)
- Custom (user-defined templates with
{tag}and{message}placeholders)
- Automatic Import Management: Imports are added when inserting logs and removed automatically when all logs for a framework are removed
- Method Execution Tracking: Automatically log method entry points
- Assignment Tracking: Log variable assignments for detailed debugging
- Custom Log Tags: Configure your own log tag/prefix for easy filtering
- Context Menu Actions: Right-click in the editor to insert or remove logs
- Tool Window: Dedicated settings panel for configuring logging preferences
- Real-time Configuration: Change settings without restarting the IDE
- Open IntelliJ IDEA
- Go to
File→Settings→Plugins - Search for "Log Injector"
- Click
Installand restart the IDE
-
Clone this repository:
git clone https://github.com/Kiolk/Log-Injector.git cd Log-Injector -
Build the plugin:
./gradlew buildPlugin
-
Install the plugin:
- Go to
File→Settings→Plugins - Click the gear icon ⚙️ and select
Install Plugin from Disk... - Select the ZIP file from
build/distributions/ - Restart IntelliJ IDEA
- Go to
- Open a Java or Kotlin file in your project
- Right-click anywhere in the editor
- Choose one of the following actions:
- Insert Logs: Adds logging statements to methods in the current class
- Remove Logs: Removes all previously inserted logs from the current class
Access the plugin settings through the LoggingOptions tool window on the right side of the IDE:
- Track Method Execution: Enable/disable method entry logging
- Track Assignments: Enable/disable variable assignment logging
- Log Tag: Set a custom prefix for your log statements (default: "Myfancy log")
- Logging Framework: Choose between System.out.println, Android Log, Timber, Napier, or Custom
class UserManager {
fun createUser(name: String, email: String): User {
val user = User(name, email)
saveToDatabase(user)
return user
}
}class UserManager {
fun createUser(name: String, email: String): User {
println("Myfancy log: createUser()")
val user = User(name, email)
saveToDatabase(user)
return user
}
}- JDK 21 or higher
- Gradle 8.x (wrapper included)
- IntelliJ IDEA 2024.3 or higher
-
Clone the repository:
git clone https://github.com/Kiolk/Log-Injector.git cd Log-Injector -
Open the project in IntelliJ IDEA:
File→Open→ Select the project directory- IntelliJ will automatically import the Gradle project
-
Run the plugin in a development instance:
./gradlew runIde
LogInjector/
├── src/
│ ├── main/
│ │ ├── kotlin/
│ │ │ └── com/github/kiolk/loggingplugin/
│ │ │ ├── actions/ # Plugin actions (Insert/Remove)
│ │ │ ├── services/ # Core logic and strategies
│ │ │ ├── settings/ # Configuration management
│ │ │ └── toolwindow/ # UI components
│ │ └── resources/
│ │ └── META-INF/
│ │ └── plugin.xml # Plugin configuration
│ └── test/
│ └── kotlin/ # Unit tests
├── build.gradle.kts # Build configuration
└── README.md # This file
- InsertLogsAction: Handles the "Insert Logs" action
- RemoveLogsAction: Handles the "Remove Logs" action
- LogInserterService: Core service for inserting logs into PSI elements
- LogStrategy: Strategy pattern implementation for different logging frameworks
- LoggingSettings: Persistent configuration storage
We welcome contributions! Here's how you can help:
- Check if the issue already exists in the Issues section
- If not, create a new issue with:
- Clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- IntelliJ IDEA version and plugin version
- Sample code (if applicable)
-
Fork the repository and create your branch from
main:git checkout -b feature/your-feature-name
-
Make your changes:
- Follow the existing code style (enforced by ktlint)
- Add tests for new functionality
- Update documentation if needed
-
Run tests to ensure everything works:
./gradlew test -
Run code quality checks:
./gradlew ktlintCheck
-
Commit your changes with a clear commit message:
git commit -m "Add feature: description of your changes" -
Push to your fork and create a Pull Request:
git push origin feature/your-feature-name
-
In your pull request description:
- Explain what changes you made and why
- Reference any related issues
- Include screenshots for UI changes
- Follow Kotlin coding conventions
- Use meaningful variable and function names
- Add comments for complex logic
- Keep functions small and focused
- Write unit tests for new features
- Ensure ktlint passes:
./gradlew ktlintFormat
- Use
./gradlew runIdeto test changes in a live IDE instance - Check plugin logs:
Help→Show Log in Finder/Explorer - Use IntelliJ's PSI Viewer:
Tools→View PSI Structure
Run all tests:
./gradlew testRun specific test:
./gradlew test --tests "LogInserterServiceTest"Build the plugin distribution:
./gradlew buildPluginThe plugin ZIP will be created in build/distributions/
To publish to JetBrains Marketplace:
-
Set up environment variables:
export PUBLISH_TOKEN="your-marketplace-token" export CERTIFICATE_CHAIN="your-certificate" export PRIVATE_KEY="your-private-key" export PRIVATE_KEY_PASSWORD="your-password"
-
Publish:
./gradlew publishPlugin
- IntelliJ IDEA: 2024.3 - 2025.3.*
- Languages: Java, Kotlin
- JDK: 21+
This project is licensed under the MIT License - see the LICENSE file for details.
Yauheni Slizh
- GitHub: @Kiolk
- Email: tyteishi@gmail.com
- Built with IntelliJ Platform SDK
- Inspired by the need for faster debugging workflows
- Thanks to all contributors!
- Android Log support (
android.util.Log) - Custom logging framework support with user-defined templates
- Custom template UI in the tool window
- Napier logging framework support
- Scope function block removal fix
- Initial release
- Support for Java and Kotlin
- Method execution tracking
- Assignment tracking
- System.out.println and Timber frameworks
- Configurable log tags
- Tool window for settings
Future features under consideration:
- Napier logging framework support
- Android Log support
- Custom log templates
- More logging framework support (Log4j, SLF4J, etc.)
- Smart log placement (avoid duplicates)
- Log level configuration
- Bulk operations across multiple files
- Integration with debugging tools
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Wiki
Made with ❤️ for developers who love clean code and efficient debugging