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

File Channel Logs in UTC Despite ‘times = local’ #4703

Closed
pavledragisic opened this issue Sep 19, 2024 · 1 comment
Closed

File Channel Logs in UTC Despite ‘times = local’ #4703

pavledragisic opened this issue Sep 19, 2024 · 1 comment
Assignees
Labels

Comments

@pavledragisic
Copy link
Member

Describe the bug
Logging file channel logs using UTC time even though it is configured to use local time by setting logging.channels.file.times = local. For console channel it is not possible to specify times parameter.

To Reproduce
Add this configuration and compare times in logs with actual time.

logging.channels.file.class = FileChannel
logging.channels.file.pattern = %Y-%m-%d %H:%M:%S.%i [%p] %s<%I>: %t
logging.channels.file.path = ${application.dir}log/${application.baseName}.log
logging.channels.file.rotation = daily
logging.channels.file.archive = number
logging.channels.file.purgeCount = 10
logging.channels.file.times = local

Expected behavior
When logging.channels.file.times = local is configured, timestamps in log file should be using local time. Also times parameter should be supported in console channel.
Currently workaround this issue is to use PatternFormatter.
Example configuration:

logging.channels.file.class = FileChannel
logging.channels.file.path = /var/log/devs/${application.baseName}.log
logging.channels.file.formatter.class = PatternFormatter
logging.channels.file.formatter.pattern = %Y-%m-%d %H:%M:%S.%i [%p] %s<%I>: %t
logging.channels.file.formatter.times = local

logging.channels.file.rotation = daily
logging.channels.file.archive = number
logging.channels.file.purgeCount = 10

logging.channels.console.class = ColorConsoleChannel
logging.channels.console.formatter.class = PatternFormatter
logging.channels.console.formatter.pattern = %Y-%m-%d %H:%M:%S.%i [%p] %s<%I>: %t
logging.channels.console.formatter.times = local
@pavledragisic pavledragisic added this to the Release 1.14.0 milestone Sep 19, 2024
@pavledragisic pavledragisic self-assigned this Sep 19, 2024
@obiltschnig
Copy link
Member

obiltschnig commented Sep 19, 2024

Check the documentation. The times parameter controls log rotation.
To specify a local time for the timestamp written to the logfile, use the %L format specifier or the times property of the PatternFormatter.

	/// Using the "times" property it is possible to specify
	/// time mode for the day/time based rotation. The following values
	/// for the "times" property are supported:
	///
	///   * utc:        Rotation strategy is based on UTC time (default).
	///   * local:      Rotation strategy is based on local time.

In fact, the FileChannel has no control over how the timestamp gets written. This is the business of the formatter.

@aleks-f aleks-f closed this as not planned Won't fix, can't repro, duplicate, stale Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants
@obiltschnig @aleks-f @pavledragisic and others