Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Daily rollover uses UTC instead of local time #213

Closed
gmk57 opened this issue Jan 23, 2020 · 7 comments · Fixed by #221
Closed

Daily rollover uses UTC instead of local time #213

gmk57 opened this issue Jan 23, 2020 · 7 comments · Fixed by #221
Milestone

Comments

@gmk57
Copy link

gmk57 commented Jan 23, 2020

Description

I configured daily rollover with TimeBasedRollingPolicy, according to example in wiki. It generally works, but rollover happens at UTC midnight, not local midnight. This may be confusing.

I know it's possible to specify time zone explicitly, but I suppose local time should be used by default, like it was in older versions (e.g. 1.1.1).

Maybe the same issue was reported at #198.

Steps to reproduce

  1. Checkout sample project
  2. Configure GMT+3 time zone on device or emulator
  3. Leave app running overnight
  4. log.txt contains events since 3:00, not 0:00

Environment

  • logback-android version: 2.0.0
  • Android version: 5.1, 6.0
  • Platform: devices, emulator
@gmk57 gmk57 added the bug label Jan 23, 2020
@stale
Copy link

stale bot commented Mar 23, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for reporting the issue.

@stale stale bot added the stale label Mar 23, 2020
@gmk57
Copy link
Author

gmk57 commented Mar 23, 2020

Hey, bot, this issue is not stale! :)

@stale stale bot removed the stale label Mar 23, 2020
@stale stale bot closed this as completed Mar 30, 2020
@gmk57
Copy link
Author

gmk57 commented Mar 30, 2020

Wait, why is this issue closed? Is it fixed?

@tony19 tony19 reopened this Mar 31, 2020
@tony19 tony19 added the pinned label Mar 31, 2020
@veN1337
Copy link
Contributor

veN1337 commented Aug 24, 2020

Any updates on this? Im experiencing the same problem for quite a while.

@enuoCM
Copy link

enuoCM commented Sep 2, 2020

I found a solution. use FileNamePattern: "%d{yyyy.MM.dd, " + TimeZone.getDefault().getID() + "}"

@veN1337
Copy link
Contributor

veN1337 commented Sep 14, 2020

@enuoCM This only works when you programmatically set the pattern, right? I'm using a logback.xml which doesn't seem to evaluate "TimeZone.getDefault().getID()".

Commit 446eb7c probably has caused this issue. It sets the timezone to "GMT" if no timezone is given instead of doing the simple "super()" call.

@dzl888
Copy link

dzl888 commented Sep 30, 2020

I found a solution. use FileNamePattern: "%d{yyyy.MM.dd, " + TimeZone.getDefault().getID() + "}"

The scheme worked. I tried it out.I am from China, so this is my use of software to translate Chinese into English, which may be difficult to read.Above this code directly into XML as if not, use a plus sign to the connection string, should be used in the Java code, rather than in XML, so I will call in the Java code TimeZone.getDefault().getID() to get the time zone id in my area, so that it can be hard code written in XML, so weakness is hard-coded, as I have the following code is only suitable for time zones in China mobile phone use:
<fileNamePattern>${EXT_DIR}/Android/data/${PACKAGE_NAME}/files/Documents/logs/log_%d{yyyy_MM_dd, Asia/Shanghai}.txt</fileNamePattern>
I don't know why the author didn't help us solve the problem when he saw it clearly. If anyone has a better plan, please also reply,thanks!

@tony19 tony19 moved this to 📋 Backlog in Next Release Nov 6, 2022
tony19 added a commit that referenced this issue Nov 6, 2022
Dont set GMT+0 timezone in RollingCalendar if no timezone is given (fixes #213)
Repository owner moved this from 📋 Backlog to ✅ Done in Next Release Nov 6, 2022
@tony19 tony19 added this to the 2.0.1 milestone Nov 6, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Nov 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants