You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2020/08/04 23:11:46 UTC

[GitHub] [logging-log4cxx] rm5248 edited a comment on pull request #31: Added documentation on non-english logging

rm5248 edited a comment on pull request #31:
URL: https://github.com/apache/logging-log4cxx/pull/31#issuecomment-668870727


   This is related to LOG4CXX-483.  I don't think there's really a bug with LOG4CXX-483, but this should help clarify.
   
   According to the [libc documentation](https://www.gnu.org/software/libc/manual/html_node/Setting-the-Locale.html), all programs start in the "C" locale by default.  The "C" locale is the [same as ANSI_X3.4-1968](https://stackoverflow.com/questions/48743106/whats-ansi-x3-4-1968-encoding).  So before you do `setlocale`, the value that I get is ANSI_X3.4-1968, which results in the output being all question marks as the log text provided is invalid ASCII.
   
   To quote the glibc documentation:
   
   > To use the locales specified by the environment, you must call setlocale. 
   
   which explains why it works after you call `setlocale`, as my locale is en_US.UTF-8.
   
   See also [this SO poston setting the default locale in C++](https://stackoverflow.com/questions/571359/how-do-i-set-the-proper-initial-locale-for-a-c-program-on-windows).  The potentially important thing is that you may need to actually do the following:
   
   ```
   std::setlocale( LC_ALL, "" ); /* Set locale for C functions */
   std::locale::global(std::locale("")); /* set locale for C++ functions */
   ```
   
   log4cxx uses the current locale set in order to output the log messages appropriately.
   
   ---
   **TL;DR** do `setlocale( LC_ALL, "" )` in your programs as startup so they use the user's language settings.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org