I recently started using Log4j. I came across a better logging technique of parameterized logging.
I referred the below link.
https://logging.apache.org/log4j/2.x/performance.html
The above link is for log4j2. But I was wondering if the same is applicable for 1.2.9
When I try to write a logger statement with parameters, I am getting below error.
The method info(Object, Throwable) in the type Category is not applicable for the arguments (String, String)
I checked the source code of
I am using log4j 1.2.9
The java code is as below.
import org.apache.log4j.Logger;
import com.test.validators.CreateValidator;
public class CreateLogic {
Logger admin = Logger.getLogger("admin");
public void createLogic(){
admin.info("This is Create Logic");
CreateValidator CreateValidator = new CreateValidator();
CreateValidator.validateCreate();
int i = 5;
admin.info("the name is {}",i);
}
}
log4j properties are as below.
log4j.logger.admin=INFO, admin
log4j.additivity.admin = false
log4j.appender.admin=org.apache.log4j.RollingFileAppender
log4j.appender.admin.File=C:\\Create.log
log4j.appender.admin.MaxFileSize=5MB
log4j.appender.admin.MaxBackupIndex=1
log4j.appender.admin.layout=org.apache.log4j.PatternLayout
log4j.appender.admin.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1} - %m%n
.info(Object message, Throwable t)is offered in both 1.x and 2.x APIs. You're issue seems to be that you're passing inias a Throwable, but it's not.