Skip to content

FileChannel compress fails leaving empty .gz files #865

@gottafixthat

Description

@gottafixthat

I have several applications that are all coded identically with regard to log files, but one of them is not able to compress its rotated logs correctly. All of the others compress and rotate logs correctly.

The only difference is that the program that is not rotating its logs correctly is very busy, and is logging hundreds of lines per minute. That also makes its log files much larger.

I've gone through the RotateStrategy code and the FileChannel code and have found nothing obvious.

Here is how the loggers are setup:

AutoPtr <ConsoleChannel> pCons(new ConsoleChannel);
AutoPtr <FileChannel> pChannel(new FileChannel);
AutoPtr <PatternFormatter> pPF(new PatternFormatter);
pChannel->setProperty("path",   "/var/log/program.log");
pChannel->setProperty("rotation", "23:59");
pChannel->setProperty("archive", "timestamp");
pChannel->setProperty("purgeAge", "30 days");
pChannel->setProperty("times", "local");
pChannel->setProperty("compress", "true");
pPF->setProperty("times", "local");
pPF->setProperty("pattern", "%Y-%m-%d %H:%M:%S.%i %q:%s %t");
AutoPtr <FormattingChannel> pFC(new FormattingChannel(pPF, pChannel));
AutoPtr <FormattingChannel> pCC(new FormattingChannel(pPF, pCons));
AutoPtr <SplitterChannel> pSplitter(new SplitterChannel);
pSplitter->addChannel(pFC);

if (!config().getBool("application.runAsDaemon", false)) {
    pSplitter->addChannel(pCC);
}

Logger::root().setChannel(pSplitter);
Logger::root().setLevel("information");

As I said, I have 5 different programs all setup identically using this, with the only difference being the "path" property. 4 of the 5 rotate their logs correctly, the 5th leaves the directory looking like this:

-rw-rw-rw- 1 root root  3421175 Jun 18 15:37 csxmlsrv.log
...
-rw-rw-rw- 1 root root 17495949 Jun 16 23:58 csxmlsrv.log.20150616235908377
-rw-rw-rw- 1 root root        0 Jun 16 23:59 csxmlsrv.log.20150616235908377.gz
-rw-rw-rw- 1 root root  5884837 Jun 17 23:58 csxmlsrv.log.20150617235903412
-rw-rw-rw- 1 root root        0 Jun 17 23:59 csxmlsrv.log.20150617235903412.gz

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions