Grails and Log4J: How to register in different files with the same level?

I would like to configure Grails log4j to store logs in different files depending on the controller.

So, I have package.Controller1 and package.Controller2. On controller 1, I would like to store in logfile1.logs and on controller2 in logfile2.logs in debug mode.

How to do it?

Thank.

+3
source share
1 answer

Create the appenders as a file (or rollFile, etc.):

appenders {
   file name: "logfile1", file: "/path/to/logfile1.logs"
   file name: "logfile2", file: "/path/to/logfile2.logs"
}

and then use the Map syntax to separate the two controllers into separate applications:

debug logfile1: "grails.app.controller.package.Controller1",
      logfile2: "grails.app.controller.package.Controller2"

See http://grails.org/doc/latest/guide/3.%20Configuration.html#3.1.2%20Logging for more details .

+3
source

All Articles