| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| ~ Licensed to the Apache Software Foundation (ASF) under one or more |
| ~ contributor license agreements. See the NOTICE file distributed with |
| ~ this work for additional information regarding copyright ownership. |
| ~ The ASF licenses this file to You under the Apache license, Version 2.0 |
| ~ (the "License"); you may not use this file except in compliance with |
| ~ the License. You may obtain a copy of the License at |
| ~ |
| ~ http://www.apache.org/licenses/LICENSE-2.0 |
| ~ |
| ~ Unless required by applicable law or agreed to in writing, software |
| ~ distributed under the License is distributed on an "AS IS" BASIS, |
| ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| ~ See the license for the specific language governing permissions and |
| ~ limitations under the license. |
| --> |
| <Configuration status="ERROR"> |
| <properties> |
| <property name="LOG_DIR">target/logs</property> |
| </properties> |
| <MarkerFilter marker="FLOW" onMatch="ACCEPT" onMismatch="NEUTRAL"/> |
| <MarkerFilter marker="Audit" onMatch="ACCEPT" onMisMatch="NEUTRAL"/> |
| <Appenders> |
| <Console name="Console" target="SYSTEM_OUT"> |
| <PatternLayout pattern="%d{ABSOLUTE} %-5level # %class.%method %m%n" /> |
| </Console> |
| |
| <RollingFile name="log4j" fileName="${LOG_DIR}/log4j.txt" filePattern="${LOG_DIR}/archive/log4j.txt.%d{yyyyMMdd_HHmmss}-%i"> |
| <PatternLayout> |
| <MarkerPatternSelector defaultPattern="%d [%t] %-5p %X{loginId, userId, ipAddress, corpAcctNumber} %C{1.}.%M:%L - %m%n"> |
| <PatternMatch key="FLOW" pattern="%d [%t] %-5p %X{loginId, userId, ipAddress, corpAcctNumber} -------- %C{1.}.%M:%L %msg --------%n"/> |
| </MarkerPatternSelector> |
| </PatternLayout> |
| <Policies> |
| <SizeBasedTriggeringPolicy size="30 MB"/> |
| </Policies> |
| <!-- A max of 20 will allow 20 files per second with the date pattern specified on the RollingFile declaration. |
| Hopefully that is a ridiculous value --> |
| <DefaultRolloverStrategy min="1" max="20"> |
| <Delete basePath="${LOG_DIR}/archive"> |
| <!-- Nested conditions: the inner condition is only evaluated on files for which the outer conditions are true. --> |
| <IfFileName glob="log4j.txt.*"> |
| <!-- Only allow 1 GB of files to accumulate --> |
| <IfAccumulatedFileSize exceeds="1 GB"/> |
| </IfFileName> |
| </Delete> |
| </DefaultRolloverStrategy> |
| </RollingFile> |
| <RollingFile name="audit" fileName="${LOG_DIR}/audit.log" filePattern="${LOG_DIR}/archive/audit.log.%d{yyyyMMdd_HHmmss}-%i"> |
| <RFC5424Layout enterpriseNumber="18060" includeMDC="true" mdcId="RequestContext" appName="SampleApp" |
| mdcPrefix="" newLine="true"/> |
| <Policies> |
| <SizeBasedTriggeringPolicy size="30 MB"/> |
| </Policies> |
| <!-- A max of 20 will allow 20 files per second with the date pattern specified on the RollingFile declaration. |
| Hopefully that is a ridiculous value --> |
| <DefaultRolloverStrategy min="1" max="20"> |
| <Delete basePath="${LOG_DIR}/archive"> |
| <!-- Nested conditions: the inner condition is only evaluated on files for which the outer conditions are true. --> |
| <IfFileName glob="audit.log.*"> |
| <!-- Only allow 1 GB of files to accumulate --> |
| <IfAccumulatedFileSize exceeds="1 GB"/> |
| </IfFileName> |
| </Delete> |
| </DefaultRolloverStrategy> |
| </RollingFile> |
| </Appenders> |
| <Loggers> |
| <Logger name="org.apache.logging.log4j.audit" level="info" additivity="false"> |
| <AppenderRef ref="log4j"/> |
| </Logger> |
| <Logger name="AuditLogger" level="trace" additivity="false"> |
| <AppenderRef ref="audit"/> |
| </Logger> |
| <Root level="warn"> |
| <AppenderRef ref="log4j" /> |
| </Root> |
| </Loggers> |
| </Configuration> |