Chaging log output destination path with log4net

log4net.Repository.ILoggerRepository[] repositories = log4net.LogManager.GetAllRepositories();
foreach (log4net.Repository.ILoggerRepository repository in repositories)
{
    foreach (log4net.Appender.IAppender appender in repository.GetAppenders())
    {
        log4net.Appender.FileAppender fileAppender = appender as log4net.Appender.FileAppender;
        if (fileAppender != null)
        {
            appender.File = "log.log"; // Set log output destination path
            appender.ActivateOptions();
        }
    }
}

* Although I have set File, I have to set File in configuration XML file.

log4netで設定したログ出力先パス、ファイル名の取得: DOBON.NETプログラミング掲示板過去ログ
log4netでのログ出力について - Insider.NET - @IT)