I'm upgrading log4j dependency in my grails 2.5.4 application from 1.2.17 to the latest version 2.17.1
I've excluded log4j from the BuildConfig.groovy and added the following dependencies pertaining to v2.17.1:
- log4j-api
- log4j-core
- log4j-1.2-api
- log4j-slf4j-impl
I'm using the log4-1.x bridge to reduce overall codebase change.
I've added the following log4j2.properties file under the conf directory:
rootLogger.level = INFO
rootLogger.additivity = false
rootLogger.appenderRefs = stdout
rootLogger.appenderRef.stdout.ref = STDOUT
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %m%n
But during the application boot-up and usage, I notice extra logs getting added to the console:
..........................................Attempting to load [0] user defined plugins
Grails plug-in [dataBinding] with version [2.5.4] loaded successfully
Grails plug-in [i18n] with version [2.5.4] loaded successfully
Grails plug-in [restResponder] with version [2.5.4] loaded successfully
Grails plug-in [core] with version [2.5.4] loaded successfully
Grails plug-in [greenmail] with version [1.3.4] loaded successfully
Grails plug-in [executor] with version [0.3] loaded successfully
Grails plug-in [webxml] with version [1.4.1] loaded successfully
Grails plug-in [cacheHeaders] with version [1.1.7] loaded successfully
Grails plug-in [browserDetection] with version [2.8.1] loaded successfully
Grails plug-in [console] with version [1.5.12] loaded successfully
Grails plug-in [remotePagination] with version [0.4.8] loaded successfully
Grails plug-in [tomcat] with version [7.0.42] loaded successfully
...
Some Hibernate logs are also appearing (didn't add the logs due to Domain information present)
It seems like the internal Grails logs are appended to the console. During application use, following kind of logs appeared:
FrameworkServlet 'gsp': initialization started
GSP servlet initialized
FrameworkServlet 'gsp': initialization completed in 39 ms
Invocation of <r:resource> for a resource that apparently doesn't exist: /assets/favicon.ico
Invocation of <r:resource> for a resource that apparently doesn't exist: /assets/spinner.gif
Invocation of <r:resource> for a resource that apparently doesn't exist: /assets/spinner.gif
Invocation of <r:resource> for a resource that apparently doesn't exist: /assets/spinner.gif
Invocation of <r:resource> for a resource that apparently doesn't exist: /assets/spinner.gif
Invocation of <r:resource> for a resource that apparently doesn't exist: /assets/spinner.gif
Invocation of <r:resource> for a resource that apparently doesn't exist: /assets/spinner.gif
...
Seems like setting the additivity property to false is not working. I tried using additive as well, but in vain.
I notice that log4j config present in Config.groovy is also not being read. Here's the config:
log4j = {
appenders {
'null' name: 'empty'
environments {
development {
'null' name: 'stacktrace'
appender name: "appLog",
new org.apache.log4j.DailyRollingFileAppender(
threshold: org.apache.log4j.Level.INFO,
datePattern: "'.'yyyy-MM-dd",
file: "/tmp/test.log",
layout: pattern(conversionPattern: '[%d{yyyy-MM-dd hh:mm:ss.SSS}] %p %c{5} %m%n'))
root {
info stdout
}
}
production {
file name: 'stacktrace', file: "/logs/stacktrace.log".toString()
root {
error 'stdout'
info stdout
}
}
}
}
// off 'ErrorsController & ResourceMeta'
off 'org.grails.plugin.resource.ResourceMeta',
'org.springframework.security.saml.metadata'
error empty: ['grails.app.services.org.grails.plugin.resource',
'grails.app.taglib.org.grails.plugin.resource',
'grails.app.resourceMappers.org.grails.plugin.resource',
'grails.app.resource.ResourceMeta']
info 'grails.plugin.springsecurity.web.filter.DebugFilter'
error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
'org.codehaus.groovy.grails.web.sitemesh', // layouts
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
'org.codehaus.groovy.grails.web.mapping', // URL mapping
'org.codehaus.groovy.grails.commons', // core / classloading
'org.codehaus.groovy.grails.plugins', // plugins
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
'org.springframework',
'org.hibernate'
debug 'org.springframework.security.saml'
warn 'org.mortbay.log'
environments {
development {
//info additivity: true, appLog: "grails.app"
}
}
root {
additivity = false
}
}
Could someone please guide what I'm doing wrong? How can I stop the internal logs from appending?