Environment variables lowercased
Cheetah
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?
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
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.
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