segunda-feira, 23 de julho de 2012

FxGqlC: DailyRollingFileAppender in log4j/log4net/log4cxx

Using log4j or one of the ports (like log4net or log4cxx), you can configure the appender to "roll" to a new file every day:
log4j.rootLogger=INFO, logfile

# logfile appender: writes its output to a file that is rolled each midnight.
log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfile.File=c:/logs/MyLogFile.log
log4j.appender.logfile.Append=true
log4j.appender.logfile.DatePattern='.'yyyy-MM-dd
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d{}{GMT} %X{pid} %X{pname} [%t-%X{tname}] %-5p - %c %m%n


This gives you one log file per day, suffixed with the date, except the last day:

  • MyLogFile.log.2012-07-21
  • MyLogFile.log.2012-07-22
  • MyLogFile.log
When running the query "select distinct $filename from [*.*]" in FxGqlC, you get this list:
MyLogFile.log
MyLogFile.log.2012-07-21
MyLogFile.log.2012-07-22

So, the most recent file is scanned first, because this is the "ascending" order as returned by the operating system.

A workaround for this is to change the query like this: "select distinct $filename from [*.log.2*], [*.log]"

This workaround also applies to the regular RollingFileAppender, based on filesize instead of date.

A future feature will be to sort the files on modification date, by extending the FROM-clause option -fileorder.  Possibly in version 2.3.

Update: the FROM-clause option -fileorder has been extended in v2.3 to allow an order based on modification time.  For more information, have a look at:
https://sites.google.com/site/fxgqlc/home/fxgqlc-manual/changes-in-fxgqlc-2-3

Nenhum comentário:

Postar um comentário