Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails 3 logging in src folder not injecting log object

Tags:

grails

grails3

In the src folder of the grails 3 app:

enter image description here

I have a lot of log.xyz and they are is throwing the following exception:

Caused by: groovy.lang.MissingPropertyException: No such property: log for class: com.myApp.runner.RunnerThreadPoolExecutor

Which seems odd as this is a migrated app from grails 2 and having the log object in those classes was very useful.

I can add the following to each class:

import org.slf4j.Logger
import org.slf4j.LoggerFactory

static Logger log = LoggerFactory.getLogger(SomeClass.class)

But this seems very long winded and a bit a backwards step. Am I missing something in the configuration somewhere?

like image 999
JoeyHolloway Avatar asked Mar 07 '23 03:03

JoeyHolloway


1 Answers

Just add the slf4j annotation to your classes:

package com.example

import groovy.util.logging.Slf4j

@Slf4j
class MySample {
   def test() {
      log.debug("log this!")
   } 
}
like image 109
Sascha Frinken Avatar answered Mar 15 '23 01:03

Sascha Frinken