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

前提是你 提交于 2019-12-06 08:38:34

问题


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.



来源:https://stackoverflow.com/questions/6330436/grails-and-log4j-how-to-logs-in-different-files-with-same-level

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!