Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Flush statistic BEFORE log file rollover #23

Open
klimchuk opened this issue Dec 12, 2013 · 2 comments
Open

Flush statistic BEFORE log file rollover #23

klimchuk opened this issue Dec 12, 2013 · 2 comments

Comments

@klimchuk
Copy link

I'm using speed4j with logback.

PeriodicalLog myLog = new PeriodicalLog();
myLog.setPeriod(3600);

Every hour stats recorded to nws log file using Logback and every day file rolled over.

<appender name="statLogFile" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>/stat/nws.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>/stat/nws_%d{yyyyMMdd}.log.gz</fileNamePattern> <maxHistory>30</maxHistory> </rollingPolicy> <encoder> <pattern>%msg%n</pattern> </encoder> </appender>

However looks like last hour of the day always transferred to next day log file and not rolled over in time like this:

Statistics from Wed Dec 11 23:00:00 UTC 2013 to Thu Dec 12 00:00:00 UTC 2013
Tag Avg(ms) Min Max Std Dev
StatusOp_1:failure 104.55 104.13 106.27 52.17

Statistics from Thu Dec 12 00:00:00 UTC 2013 to Thu Dec 12 01:00:00 UTC 2013
Tag Avg(ms) Min Max Std Dev
StatusOp_1:failure 104.82 104.07 140.47 52.36

Statistics from Thu Dec 12 01:00:00 UTC 2013 to Thu Dec 12 02:00:00 UTC 2013
Tag Avg(ms) Min Max Std Dev
StatusOp_1:failure 104.31 104.01 105.01 52.03

Statistics from Thu Dec 12 02:00:00 UTC 2013 to Thu Dec 12 03:00:00 UTC 2013
Tag Avg(ms) Min Max Std Dev
StatusOp_1:failure 104.23 103.94 105.08 52.01

Is there any way to make sure data flushed BEFORE file rolled over?

@jalkanen
Copy link
Owner

Great catch. This may be a bit hard to fix tho' - 'cos we wait until all the data has come for the full minute/hour. And this means a race condition between Speed4j and the logging library, which we lose. So I don't know if there's a good way to solve this really...

@klimchuk
Copy link
Author

Doesn't sound good. Is it possible flush stats manually?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants