Open jeffscottbrown opened 6 years ago
@Slf4j
is the default for 3.3 I believe
@Slf4j is the default for 3.3 I believe
That is true, but the code below won't compile with 3.3.3 unless @Slf4j
is explicitly added the class...
class DemoService {
static void someMethod() {
log.error 'This is an error message'
}
}
FYI... The project at github.com/jeffbrown/issue10969 indicates this is still a problem with Grails 4.0.9.
grails-app/services/issue10969/DemoService.groovy
package issue10969
import groovy.util.logging.Slf4j
// https://github.com/grails/grails-core/issues/10969
//
// Adding the @Slf4j annotation allows the code to compile.
//
//@Slf4j
class DemoService {
static void someMethod() {
log.error 'This is an error message'
}
}
FYI... I have verified this phenomenon still exists in Grails 6.2.1. Without the @Slf4j
annotation the log
property really is added to the class, like this...
private static final transient Logger log
I am only speculating but I suspect that the log
property is being added too late for a static method in the class to reference it.
That code won't compile...
This does compile...
Another way to make this work is to mark the class with
@Slf4j
.It is a little unusual to have static methods in a Grails artifact like this, but it probably should be allowed to work.