Below is my log4j property file and I want to make all loggers asynchronous. our projects runs on WebSphere server and we use buld.xml to build the application.
log4j.properties
log4j.rootLogger=warn, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %5p [%t] (%F:%L) - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/export/opt/applications/gce/computegrid/logs/abcappxd.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %p %t %c - %m%n
Below is the AppLogger class which we use to log the messages.
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
public class AppLogger implements IAppLogger {
private static AppLogger instance = null;
private transient Logger logger;
private static final String LOGGER_NAME = " ";
private static String SERVER_NAME = " ";
private AppLogger() {
this.logger = LogManager.getLogger (LOGGER_NAME);
try {
AdminService adminService = AdminServiceFactory.getAdminService();
SERVER_NAME = adminService.getProcessName();
} catch (Exception e) {
SERVER_NAME="LOCAL";
}
}
public static synchronized AppLogger getInstance() {
if (instance == null) {
instance = new AppLogger ();
}
return instance;
}
public void logDebug(final String strMsg, ContextInfoVO contextInfo, final String strClassName,final String strMethodName){
logMessage(strMsg, contextInfo, strClassName, strMethodName, Level.DEBUG);
}
}
Below is the class where we use AppLogger Instance to print loggers
public class Dummy {
private static AppLogger logger = AppLogger.getInstance();
void dummyMethod(){
logger.logDebug(strMsg, contextInfo, strClassName, );
}
}
Please help me on how I can Implement asynchronous logger in above code.