I have the following log4j2 configuration:
<?xml version="1.0" encoding="UTF-8"?> <Configuration status="WARN"> <Properties> <Property name="LOG_DIR">${sys:web.root}/logs</Property> <Property name="ARCHIVE">${LOG_DIR}/archive</Property> </Properties> <Appenders> <Console name="console-log" target="SYSTEM_OUT"> <PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"/> </Console> <RollingFile name="paypal-log" fileName="${LOG_DIR}/paypal.log" filePattern="${ARCHIVE}/paypal.log.%d{yyyy-MM-dd-hh-mm}.gz"> <PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"/> <Policies> <TimeBasedTriggeringPolicy interval="5" modulate="true"/> </Policies> </RollingFile> </Appenders> <Loggers> <Logger name="com.retailstore.paypal" level="info" additivity="false"> <appender-ref ref="paypal-log" level="info"/> </Logger> <Root level="error" additivity="false"> <AppenderRef ref="console-log"/> </Root> </Loggers> In my (Eclipse) web application I have a class com.retailstore.paypal.paypalfunctions in which I have
private static final Logger logger = LogManager.getLogger(paypalfunctions.class.getName()); ... logger.error("paypal error"); But there is no logs/paypal.log under the Webcontent folder. Where should it appear? If I remove the logger the console output seems to work.
OUTPUT with TRACE:
2016-05-23 19:24:03,231 http-nio-8080-exec-2 TRACE PatternProcessor.getNextTime returning 2016/05/23-19:25:00.000, nextFileTime=2016/05/23-19:24:00.000, prevFileTime=2016/05/23-19:14:00.000, current=2016/05/23-19:24:03.230, freq=EVERY_MINUTE 2016-05-23 19:24:03,247 http-nio-8080-exec-2 TRACE DefaultRolloverStrategy.purge() took 15.0 milliseconds 2016-05-23 19:24:03,254 http-nio-8080-exec-2 DEBUG RollingFileManager executing synchronous FileRenameAction[${sys:web.root}/logs/paypal.log to ${sys:web.root}/logs/archive/paypal.log.2016-05-23-07-14, renameEmptyFiles=false] 2016-05-23 19:24:03,256 http-nio-8080-exec-2 DEBUG RollingFileManager executing async GzCompressAction[${sys:web.root}/logs/archive/paypal.log.2016-05-23-07-14 to ${sys:web.root}/logs/archive/paypal.log.2016-05-23-07-14.gz, deleteSource=true]