Below is a configuration file for log4j. Log4j2 can use the same syntax, but there are different appender classes:
log4j.rootLogger=INFO, FOO
## ConsoleAppender
log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern= %d{hh:mm:ss,SSS} [%t] %-5p %c %x - %m%n
## FileAppender
log4j.appender.FOO=org.apache.log4j.RollingFileAppender
log4j.appender.FOO.File=${catalina.home}/logs/app.log
log4j.appender.FOO.Append=true
log4j.appender.FOO.layout=org.apache.log4j.PatternLayout
log4j.appender.FOO.layout.ConversionPattern= %d{hh:mm:ss,SSS} [%t] %-5p %c %x - %m%n
## attaching appender to specific package:
log4j.logger.com.example.package=INFO, CA
Directive log4j.rootLogger
defines log level and appender for any class that doesn't meet logger
criteria. Notice that appender name
is defined after word 'appender'.