Hi All,

I've been using log4net on an xp platform, and I wanted each users log file
to go into their separate user folders.  To achieve this, I've changed the
FileAppender.ConvertToFullPath method as follows.

protected static string ConvertToFullPath(string path)
{
        if (path == null)
        {
                throw new ArgumentNullException("path");
        }

        string expandedPath = Environment.ExpandEnvironmentVariables(path);

        if (SystemInfo.ApplicationBaseDirectory != null)
        {
                // Note that Path.Combine will return the second path if it is 
rooted
                return Path.GetFullPath(
                        Path.Combine(SystemInfo.ApplicationBaseDirectory, 
expandedPath));
        }
        return Path.GetFullPath(expandedPath);
}

Pretty much the same as how it was, just expanded the env variables between
getting the full path.  This way the file '%USERPROFILE%\mylog.txt' will go
into the user folder.  Is this something that would be useful for others, or
is this functionality already present somewhere, and I've overlooked it?

Cheers -Mike

"The pure and simple truth is rarely pure and never simple."
Oscar Wilde

Reply via email to