-->

Grails and Log4J : How to logs in different files

2020-07-18 11:49发布

问题:

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

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

How to do that ?

Thanks.

回答1:

Create the appenders as file (or rollingFile 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 partition the two controllers into separate appenders:

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

See http://docs.grails.org/latest/guide/conf.html#logging for more details.



标签: grails log4j