Uploaded image for project: 'Log4cxx'
  1. Log4cxx
  2. LOGCXX-378

Unicode characters not substituted correctly from environment variables in log configuration file

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Duplicate
    • 0.10.0
    • None
    • Configurator
    • None
    • Windows 7 64 bit, log4cxx built with VS2005

    Description

      Under region and language in the control panel, everything is set to English (United States) The user name has Chinese characters which are interpreted correctly in Windows Explorer and in my Unicode MFC application.

      When using environment variables for the filename (not the path) I get a file output but the characters of the file name are garbled (from some other language).

      If I execute the following code snippet, it interprets the environment variable correctly and the file is output with the correct path and file name.

      wchar_t lPathPtr[2048];
      size_t lPathSize = 0;
      _wgetenv_s( &lPathSize, lPathPtr, 2048, L"APPDATA" );
      if ( lPathPtr != NULL )

      { wchar_t lPath[2048]; StringCbPrintfW(lPath, 2048, L"%s\\unicode_test.txt", lPathPtr); log4cxx::LayoutPtr layout(new log4cxx::SimpleLayout()); log4cxx::FileAppenderPtr appender(new log4cxx::FileAppender(layout, lPath, true)); LoggerPtr logger(Logger::getLogger("MyApp")); logger->addAppender( appender ); wchar_t lString[512]; mTextBox.GetWindowTextW( lString, 512 ); LOG4CXX_INFO(logger, lString ); }

      However if I create a configuration file that looks like this...

      log4j.rootLogger=info, R
      log4j.appender.R=org.apache.log4j.RollingFileAppender
      log4j.appender.R.File=${TESTENV}
      log4j.appender.R.MaxFileSize=100KB
      log4j.appender.R.MaxBackupIndex=1
      log4j.appender.R.layout=org.apache.log4j.PatternLayout
      log4j.appender.R.layout.ConversionPattern=%r %p %t %c - %m%n

      ...and open that configuration file with a code snippet that looks like this...
      LoggerPtr logger(Logger::getLogger("MyApp"));
      PropertyConfigurator::configure("test.logcfg");
      LOG4CXX_INFO(logger, "Entering application.");

      ... the file name ends up being garbled with funny characters.
      Obviously if I replace ${TESTENV} with ${APPDATA}/unicode_test.txt, I don't see any output because the garbled folder path doesn't exist. This seems to be the case for European characters outside of the ascii range as well (like the german umlaut or the accent aigu in French).

      Attachments

        Issue Links

          Activity

            People

              carnold@apache.org Curt Arnold
              jason83 Jason Whitwill
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: