Grails log4j diffrerent appenders according to files

I want to register in different applications depending on the module ...

I have 3 applications: a console, a sliding file for registering the controller and services, and another sliding file for registering some things in tasks. I want to write the job code only for its sliding file and register the controllers and services with only another sliding file.

So this is my grails log4j configuration:

development { def catalinaBase = System.properties.getProperty('catalina.base') if (!catalinaBase) catalinaBase = '.' def logDirectory = "${catalinaBase}/logs/AmbienticWebsite" log4j = { appenders { console name:'stdout', layout:pattern(conversionPattern: '%c{2} [%p] - %m%n') appender new DailyRollingFileAppender( name: "rollingFileGrailsApp", file: "${logDirectory}/GrailsApp.log", datePattern: "'.'yyyy-MM-dd", layout: pattern(conversionPattern: commonPattern) ) appender new DailyRollingFileAppender( name: "rollingFileImport", file: "${logDirectory}/Imports.log", datePattern: "'.'yyyy-MM-dd", layout: pattern(conversionPattern: commonPattern) ) } root { error 'stdout', 'rollingFileImport', 'rollingFileGrailsApp' // both stdout and AmbienticWebsite_dev.log are filled by logging information additivity = false } debug rollingFileImport: 'ambienticwebsite.EventImportJob', 'time2marketing.time2marketingImportService', 'eventImportData.DiscomImportDataService', 'eventImportData.EventImportService' info rollingFileGrailsApp: 'ambienticwebsite', 'ambienticwebsite.jobManagement.AmbienticJobListener', 'BootStrap', 'grails.app.controllers', 'grails.app.services' } } 

In this configuration, the logs are written in two files for drag and drop and stdout. If I delete sliding applications from the root directory, the drag-and-drop file remains empty, even if additional applications are specified for the group of files.

Does anyone have any advice to separate the log from applications?

+2
source share
1 answer

I think you need to add additivity: false to user applications.

 debug rollingFileImport: [foo, bar, baz] additivity: false info rollingFileGrailsApp: [foo1, bar1, baz1] additivity: false 

Refer to "Inheritance of an inheritor" in grails.

+1
source

Source: https://habr.com/ru/post/1501183/


All Articles