Options

Environment variables lowercased

CheetahCheetah Posts: 17
I was noticing that log files from my application end up in the wrong place when running under the profile, and found that, when running under ANTS, the names of all the environment variables get lowercased.

Thus, my log4net configuration that says to log to ${TEMP}\appname.log doesn't see any "TEMP" environment variable, and ends up logging to C:\appname.log.

Is there a workaround or fix for this?

Comments

  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi Cheetah,

    The .NET Framework uses a StringDictionary to copy over existing environment variables when you add environment variables to a process in code like ANTS Profiler does. StringDictionary converts all keys to lower-case when it is used, and this is why all of the environment variables in your process end up in lower-case when ANTS Profiler adds the necessary profiler environment variables to your process. Normally this is not a problem in the case-insensitive world of Windows, but could be a problem in open-source derived projects.

    I don't have any suggestions to work around this -- clearly even changing the environment variable to upper-case in your own code would be futile as .NET is going to convert to lower-case automatically.

    The best I can do for you is log a bug to our development team -- there should be an equivilent Windows native API function that can manage the process environment block instead of the .NET ProcessStartInfo.EnvironmentVariables property and hopefully it doesn't exhibit this behaviour.
  • Options
    Thanks for the explanation of why this is happening. Given that, I'll file a bug with the open source component (log4net). Given that environment variables are supposed to be case insensitive on windows, it seems that log4net should treat them that way on that problem. I wonder how these APIs might mess with things in the *nix/Mono world though.

    For reference, in case someone else comes across this forum topic, I submitted the bug to log4net as https://issues.apache.org/jira/browse/LOG4NET-132
Sign In or Register to comment.