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

Locale for String formatting #87

Closed
schildbach opened this issue Feb 18, 2015 · 9 comments
Closed

Locale for String formatting #87

schildbach opened this issue Feb 18, 2015 · 9 comments
Labels

Comments

@schildbach
Copy link

Whenever there is any String formatting we need a way to supply a Locale.

e.g. I use filePattern.setPattern("%d{HH:mm:ss.SSS} [%thread]"); and in the Arabic world this yields log lines like this:

١٨:٣٧:١١.٧٢٧ [main] …

A similar thing happens for the filenames of rolling logs:

rollingPolicy.setFileNamePattern("/%d.log.gz");

yields files named like this:

٢٠١٥-٠٢-١٦.-1847019678.log.gz

You may notice these filenames are writting from right to left partially. (-:

@tony19
Copy link
Owner

tony19 commented Feb 19, 2015

What are the expected values for your examples?

@schildbach
Copy link
Author

Well, Latin numbers. Something like 2015-02-19 etc. If there were a locale, I'd probably pick Locale.US.

@tony19
Copy link
Owner

tony19 commented Feb 19, 2015

Are you saying the locale should be hard-coded to US? You mentioned partial right-to-left (and I'm not sure what the full line is supposed to look like), so I'm a little confused.

@schildbach
Copy link
Author

No. What I meant is:

Whenever there is any String formatting we need a way to supply a locale.

I personally will set this locale to Locale.US for all of my apps. I can imagine devs from "non-latin-number countries" may decide different.

@schildbach
Copy link
Author

Regarding RTL: try cut & paste (or even just text selection) on my first comment #87 (comment) , second to last line. You'll see it's mixed LTR/RTL.

@guohai
Copy link

guohai commented Sep 3, 2015

I'm also facing this problem.
For me, I prefer timestamp in log is like this

2015-07-13 16:48:25.823+0800 [Thread-128] DEBUG

not like this

٢٠١٥-٠٩-٠٣ ٠٩:٠٢:٤٢.٤٩٥+0400 [main] INFO

tony19 added a commit that referenced this issue Sep 4, 2015
The date conversion pattern previously assumed the system default locale,
which caused undesired localization of dates in logs (where log lines
would be partially translated).

This patch defaults the locale to US/English so that the dates and logs
are presented in a consistent form.
tony19 added a commit that referenced this issue Sep 4, 2015
The date conversion pattern now accepts a locale option (in the third
option position).

Examples:

  %d{HH:mm:ss,EST,fr}
  %d{HH:mm:ss,EST,"zh,CN"}
  %d{HH:mm:ss,EST,"hi,IN"}
@tony19
Copy link
Owner

tony19 commented Sep 4, 2015

The locale can now be specified in date conversion patterns in the third option position. By default, the US/English locale is assumed.

Examples:

  %d{HH:mm:ss,EST,fr}
  %d{HH:mm:ss,EST,"zh,CN"}
  %d{HH:mm:ss,EST,"hi,IN"}

@tony19 tony19 closed this as completed Sep 4, 2015
@tony19
Copy link
Owner

tony19 commented Apr 8, 2016

Released in 1.1.1-5

@lock
Copy link

lock bot commented Feb 27, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the archived label Feb 27, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants