https://github.com/felixklauke/guice-logback
Use google guice custom dependency injection to inject logback loggers. Makes it very easy to create class depending loggers instead of default java.util.Logger injection.
https://github.com/felixklauke/guice-logback
custom-injection dependency-injection extension google google-guice guice guice-extension logback logback-injection
Last synced: 6 months ago
JSON representation
Use google guice custom dependency injection to inject logback loggers. Makes it very easy to create class depending loggers instead of default java.util.Logger injection.
- Host: GitHub
- URL: https://github.com/felixklauke/guice-logback
- Owner: felixklauke
- License: mit
- Created: 2018-01-26T11:35:23.000Z (over 7 years ago)
- Default Branch: dev
- Last Pushed: 2023-06-14T05:03:17.000Z (over 2 years ago)
- Last Synced: 2025-02-09T23:17:04.234Z (8 months ago)
- Topics: custom-injection, dependency-injection, extension, google, google-guice, guice, guice-extension, logback, logback-injection
- Language: Java
- Homepage: http://felix-klauke.de
- Size: 38.1 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Logback Custom Injection for Google Guice
Ever tried dependency injection while you still want class specific logging? If you
don't want to break the sense of dependency injection you shouldn't use a static
factory in each class. Google Guice even supports logger injection but sadly only
for the default java.util.Logger. Be serious: Who really uses this in production
on enterprise level? We wan't custom injection of our own logging framework.
In this case we will use logback as our logging framework.# Usage
- Install [Maven](http://maven.apache.org/download.cgi)
- Clone this repo
- Install: ```mvn clean install```**Maven dependencies**
```xml
de.felix-klauke
google-guice-logback
1.0-SNAPSHOT
compile```
# Example / How To
First you will have to install our module in your injector. You can put the module
in the injector creation or install our module in your main module.```java
Injector injector = Guice.createInjector(new MyCoolModule(), new LogbackModule());
``````java
@Override
protected void configure() {
install(new LogbackModule);
}
```As soon as the module is installed you can use on any field:
```java
@InjectLogback private Logger logger;
```