Grails

Allow for easy switching from log4j to a different logging provider

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 2.0-RC1
  • Component/s: Build System, Configuration
  • Labels:
    None

Description

Despite using the SLF4J APIs under the hood, it is currently not trivial to switch out the log4j dependency for another logging provider (such as logback). Since logging is likely to be a common point of integration across many apps running in a web-app container, Grails should not force a specific logging provider on the user.

I would like to see Grails make it as easy to switch logging providers as it currently is to switch application servers or database providers.

Activity

Hide
Graeme Rocher added a comment -

It should be easier now since direct references to Log4j have been removed from the codebase and the default logging plugin can be disabled by doing:

inherits("globals") {
    excludes "grails-plugin-logging"
}

Or by providing a different plugin that evicts the default logging plugin.

Show
Graeme Rocher added a comment - It should be easier now since direct references to Log4j have been removed from the codebase and the default logging plugin can be disabled by doing:
inherits("globals") {
    excludes "grails-plugin-logging"
}
Or by providing a different plugin that evicts the default logging plugin.
Hide
Cameron Braid added a comment -

I am using grails 2.0.0.M2 and am trying to change from log4j to logback

I added
inherits("global") { excludes "grails-plugin-logging" }

Though when running run-app I get :

Error Error: The following plugins failed to load due to missing dependencies: [resources]
  • Plugin: resources
  • Dependencies:
    ! logging (Required: 1.0 > *, Found: Not Installed) tok2-inline-tok

Is there a way around this ?

Show
Cameron Braid added a comment - I am using grails 2.0.0.M2 and am trying to change from log4j to logback I added inherits("global") { excludes "grails-plugin-logging" } Though when running run-app I get :
Error Error: The following plugins failed to load due to missing dependencies: [resources]
  • Plugin: resources
  • Dependencies: ! logging (Required: 1.0 > *, Found: Not Installed) tok2-inline-tok
Is there a way around this ?
Hide
Graeme Rocher added a comment -

Cameron: uninstall the resources plugin and raise a JIRA at http://jira.grails.org/browse/GPRESOURCES to remove the dependency on logging from resources

Show
Graeme Rocher added a comment - Cameron: uninstall the resources plugin and raise a JIRA at http://jira.grails.org/browse/GPRESOURCES to remove the dependency on logging from resources
Hide
Marc Palmer added a comment -

I'm not sure this is so simple. The dependency is there if I recall, because we require access to logs at startup. How can we do this in a logging-agnostic way?

Show
Marc Palmer added a comment - I'm not sure this is so simple. The dependency is there if I recall, because we require access to logs at startup. How can we do this in a logging-agnostic way?
Hide
Peter Ledbrook added a comment -

Graeme: Won't excluding grails-plugin-logging also disable the 'log' property injection? If that's the case, isn't the correct fix to split the 'log' property injection from the custom SLF4J implementation?

Show
Peter Ledbrook added a comment - Graeme: Won't excluding grails-plugin-logging also disable the 'log' property injection? If that's the case, isn't the correct fix to split the 'log' property injection from the custom SLF4J implementation?
Hide
Peter Ledbrook added a comment -

Also, can I hijack this issue to remove the log4j dependency in the Grails POMs? At the moment I believe you have to exclude grails-plugin-logging and the log4j dependencies.

Show
Peter Ledbrook added a comment - Also, can I hijack this issue to remove the log4j dependency in the Grails POMs? At the moment I believe you have to exclude grails-plugin-logging and the log4j dependencies.
Hide
Peter Ledbrook added a comment -

Latest change seems to working well apart from if Log4j gets excluded:

| Error Error executing script RunApp: org/apache/log4j/PropertyConfigurator
java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
	at org.springframework.util.Log4jConfigurer.initLogging(Log4jConfigurer.java:72)
	at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1165)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.PropertyConfigurator
	... 2 more
| Error Error executing script RunApp: org/apache/log4j/PropertyConfigurator
Show
Peter Ledbrook added a comment - Latest change seems to working well apart from if Log4j gets excluded:
| Error Error executing script RunApp: org/apache/log4j/PropertyConfigurator
java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
	at org.springframework.util.Log4jConfigurer.initLogging(Log4jConfigurer.java:72)
	at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1165)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.PropertyConfigurator
	... 2 more
| Error Error executing script RunApp: org/apache/log4j/PropertyConfigurator
Hide
Graeme Rocher added a comment -

The NoClassDefFoundError should no longer occur, So i regard this as fixed

Show
Graeme Rocher added a comment - The NoClassDefFoundError should no longer occur, So i regard this as fixed

People

Vote (14)
Watch (9)

Dates

  • Created:
    Updated:
    Resolved: