Search code examples
springloggingslf4jlog4j2tapestry

Tapestry 5 + log4j2


Has somebody ever tried to use default built in slf4j with log4j2 in Tapestry 5.4? I can use the log4j2 like this:

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
...    
private Logger logger = LogManager.getLogger(this.getClass());

But I can not use like this:

import org.apache.tapestry5.ioc.annotations.Inject; 
import org.slf4j.Logger;
... 
@Inject private Logger logger;

I can not understand why, because I think, I added to my gradle script the required libs:

runtime group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.8'
runtime group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.8'
runtime group: 'org.apache.logging.log4j', name: 'log4j-web', version: '2.8'
runtime group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.8'

Has anyone any idea, why does it not work for me?

Thanks in advance!


Solution

  • I was helped out, and I found a solution, I had to change the gradle file to this:

    compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.8'
    compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.8'
    compile group: 'org.apache.logging.log4j', name: 'log4j-web', version: '2.8'
    compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.8'