I am trying to integrate Perf4j v0.9.16 with log4j v1.2.17.
Below is Utils class which has a method.
public class Utils {
private static Logger logger = Logger.getLogger(Utils.class);
@Profiled
public String checkNullValueForString(Object obj)
{
String resultStr = "";
if(obj != null)
{
logger.info("Object is not null.");
resultStr = String.valueOf(obj);
}
logger.info("Resultstr is "+resultStr);
return resultStr;
}
}
Below is log4j.properties file:
# Define the root logger with appender file
log = /usr/home/log4j
log4j.rootLogger = DEBUG, FILE
org.perf4j.log4j = INFO
# Define the file appender
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File= logs/log.out
# Define the layout for file appender
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=%m%n
When i run the utils method its print the logger message but perf4j logger doesn’t print.
Please help.
From the Perf4J documentation
There are aspect classes provided for both the above AOP frameworks. You just need to add some configuration files to get going.
Read the Perf4J documentation at http://perf4j.codehaus.org/devguide.html#Unobtrusive_Logging_with_Profiled_and_AOP to understand how to do this.