<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-log</artifactId>
<version>1.0</version>
</dependency>
import com.jcabi.log.Logger;
import com.jcabi.log.VerboseRunnable;
public class StudentLibrary {
@Loggable(Loggable.ERROR)
public void addStudent(Student student) {
Logger.info(this, "Adding student: %s", student.getName());
Logger.info(this, "Student added successfully");
}
}
import com.jcabi.log.Logger;
import com.jcabi.log.Slf4jLogger;
import com.jcabi.log.VerboseRunnable;
public class StudentLibrary {
public StudentLibrary() {
Logger.setLogger(Slf4jLogger.class);
Logger.setOutput(Output.DISCARD);
}
@Loggable(Loggable.ERROR)
public void addStudent(Student student) {
Logger.info(this, "Adding student: %s", student.getName());
Logger.info(this, "Student added successfully");
}
}
public static void main(String[] args) {
StudentLibrary library = new StudentLibrary();
Student student = new Student("John Doe");
library.addStudent(student);
}