Reputation: 2882
I want to use Lombok @Log
or @Slf4j
but when I create:
@Log
public class Test{
public Test(){
log.error("Something's wrong here");
}
}
in log, I do not have got an error method. I have info
and warning
I have only log()
method.
I tried to add mave dependency to Slf4j library, but it did not help.
Upvotes: 4
Views: 7827
Reputation: 1069
An SLF4J implementation needs to be present in classpath. I added Logback :
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.5</version>
</dependency>
Upvotes: 0
Reputation: 2882
I found that spring boot include libries automaticly. I add this libs to my not spring project and all work fine
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
</dependency>
LogTest
@Slf4j
@NoArgsConstructor
@Data
public class LogTest {
public void test(){
log.error("fdfzsdf");
}
}
Upvotes: 0
Reputation: 10127
Lombok's @Log annotation inserts
private static final java.util.logging.Logger log = ...;
See the javadoc of java.util.logging.Logger.
You are right, it has no error(String msg)
method.
But it has a severe(String msg)
method
and a throwing(String, String, Throwable)
doing what you want.
Upvotes: 4