why 2 log files getting created when date changes

when i am running a batch [spring-batch] , and if the system date chages
two log files getting created.
i have shared my file appender.

for example :

when i started my batch at 23.45 [today 05-01-12] it will created a log with todays date
and when date changes, it will create a one more log file [tommorow 06-01-12] and start appending to that new log file.

i am expecting only one log file for my batch regardless of time when batch started.


MyFileAppender.java
nkk1712Asked:
Who is Participating?
 
gordon_vt02Commented:
It looks like the append() method in your logger creates the new file when the date rolls.  What functionality is missing from the standard DailyRollingFileAppender that you need to create a custom one?  From the sounds of it, you don't want a Rolling appender anyway, the requirement you described lends itself to just using the basic FileAppender, which will log to a single file.
0
 
nkk1712Author Commented:
and this is my log4j.xml file

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

      <appender name="FILE" class="caf.opm.cpm.feed.common.utils.OpmDailyRollingFileAppender">
            <param name="directory" value="D:\\Homeware\\CPMFeeds\\logs\\" />
            <param name="prefix" value="${feed.name}-" />
            <layout class="org.apache.log4j.PatternLayout">
                  <param name="ConversionPattern"
                        value="%-5p - %d - %C{1}.%M(%L) | %m%n" />
            </layout>
      </appender>
      
      <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
            <layout class="org.apache.log4j.PatternLayout">
                  <param name="ConversionPattern"
                        value="%-5p - %d (%-10.10t)- %C{1}.%M(%L) | %m%n" />
            </layout>
            <filter class="org.apache.log4j.varia.LevelRangeFilter">
              <param name="levelMin" value="INFO"/>
              <param name="levelMax" value="FATAL"/>
           </filter>
      </appender>

      <logger name="org.hibernate">
            <level value="ERROR" />
      </logger>

      <logger name="org.springframework">
            <level value="ERROR" />
      </logger>
      
      <logger name="dfi.fin.dcm.techfwk">
            <level value="INFO" />
      </logger>
      
      <logger name="caf.opm.cpm">
            <level value="INFO" />
      </logger>

      <root>
            <level value="ERROR" />
            <appender-ref ref="CONSOLE" />
            <appender-ref ref="FILE" />
      </root>
      
</log4j:configuration>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.