0

I have a log4j2.xml which is rolling out 2 files one of which is a trace log file, that trace log file is rolled out size based and the limit is 10 MB. But I deleted the trace log file before it reached its limit. My question is, shouldn't it make a trace log file after I deleted it ?

Here is my configuration file

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Configuration status="WARN">
 <Properties>
  <Property name="log-path">filepath to logs</Property>
 </Properties>
 <Appenders>
  <RollingFile fileName="${log-path}/Splunk-${date:yyyy-MM-dd}.log"
               filePattern="${log-path}/Splunk-%d{yyyy-MM-dd}.log"
               name="info-log">
   <Filters>
    <ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
    <ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
    <ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
    <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
   </Filters>
   <PatternLayout>
    <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS}  %msg%n</pattern>
   </PatternLayout>
   <Policies>
    <TimeBasedTriggeringPolicy interval="1" modulate="true"/>
   </Policies>
  </RollingFile>
  <RollingFile fileName="${log-path}/Splunk-trace.log"
               filePattern="${log-path}/SplunkOADC-trace-%d{yyyy-MM-dd}.log"
               name="trace-log">
   <Filters>
    <ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
    <ThresholdFilter level="fatal" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
    <ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
    <ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
    <ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY"/>
    <ThresholdFilter level="FATAL" onMatch="ACCEPT" onMismatch="DENY"/>
   </Filters>
   <PatternLayout>
    <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n</pattern>
   </PatternLayout>
   <Policies>
    <SizeBasedTriggeringPolicy size="10 MB"/>
   </Policies>
  </RollingFile>
 </Appenders>
 <Loggers>
  <Logger level="all" name="Package-Name">
   <AppenderRef ref="info-log"/>
   <AppenderRef ref="trace-log"/>
  </Logger>
  <Root></Root>
 </Loggers>
</Configuration>

Also my question is that my info log should be generated date wise. I have set TimeBasedTriggeringPolicy as "1". But I think it will calculate 24 hours after the file is created. I dont want that. How do I achieve that ?

julien carax
  • 323
  • 6
  • 22
  • 1
    With regards to the log not being recreated, this seems to be a problem multiple people have asked about: http://stackoverflow.com/questions/9937796/log4j-does-not-recreate-files-on-deletion – Display Name is missing Dec 19 '14 at 16:19
  • The problem is with the permissions in my linux server's filepath. It is working now. But there's still a problem with the functionality – julien carax Dec 20 '14 at 08:05

0 Answers0