In java, how to write logs to a specific file appender of log4j?

This might help:-

log4j.appender.successLog=org.apache.log4j.FileAppender
log4j.appender.successLog.File=${dd.log.dir}/success.log

log4j.appender.tempLog=org.apache.log4j.FileAppender
log4j.appender.tempLog.File=${dd.log.dir}/Temp_error.tmp_log

log4j.category.successLogger=INFO, successLog
log4j.additivity.successLogger=false

log4j.category.tempLogger=INFO, tempLog
log4j.additivity.tempLogger=false

Access them like:-

static final Logger successLog = Logger.getLogger("successLogger");
static final Logger tempLog = Logger.getLogger("tempLogger");