Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6839585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:44:11+00:00 2026-05-26T23:44:11+00:00

I am using log4net within a Console Application. My configuration file allow me to

  • 0

I am using log4net within a Console Application. My configuration file allow me to get the filename from Input:

Config file:

<appender name="CustomRollingFileAppender" type="MyApp.UTIL.CustomRollingFileAppender">
      <threshold value="ALL"/>
      <param name="file" value=""/>
      <param name="appendToFile" value="false"/>
      <param name="maximumFileSize" value="20000KB"/>
      <param name="maxSizeRollBackups" value="200"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%-5.5level] %logger - %message%newline"/>
      </layout>
</appender>

Override File Parameter:

namespace ConsoleApplicationTemplate.UTIL
{
    public class CustomRollingFileAppender : log4net.Appender.RollingFileAppender
    {
        public override string File
        {
            get { return base.File; }
            set
            {
                //Filename string taken as Input
                base.File = Program.options.LogFile; 
            }
        }
    }    
}

This is working like a charm, but I need to change the parameter type inside the tag appender. I have searched around and find out that I can use properties within configuration file. So I have modified my config file as following:

<appender name="CustomRollingFileAppender" type="%property{ApplicationName}.UTIL.CustomRollingFileAppender">
      <threshold value="ALL"/>
      <param name="file" value=""/>
      <param name="appendToFile" value="false"/>
      <param name="maximumFileSize" value="20000KB"/>
      <param name="maxSizeRollBackups" value="200"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%-5.5level] %logger - %message%newline"/>
      </layout>
</appender>

And I also need to change the property value as following:

log4net.GlobalContext.Properties["ApplicationName"] = Assembly.GetExecutingAssembly().GetName().Name;
private static log4net.ILog _logger = LogManager.GetLogger(typeof(Program));
log4net.Config.XmlConfigurator.Configure();

When log4net read the configuration file I get the following error (which doesn’t raise an exception):

log4net:ERROR Could not create Appender [CustomRollingFileAppender] of type [%property{ApplicationName}.UTIL.CustomRollingFileAppender]. Reported error follows.
System.TypeLoadException: Could not load type [%property{ApplicationName}.UTIL.CustomRollingFileAppender]. Tried assembly [log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a] and all loaded assemblies 
    at log4net.Util.SystemInfo.GetTypeFromString(Assembly relativeAssembly, String typeName, Boolean throwOnError, Boolean ignoreCase)
    at log4net.Util.SystemInfo.GetTypeFromString(String typeName, Boolean throwOnError, Boolean ignoreCase) 
    at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlEle
    ment appenderElement)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:44:11+00:00Added an answer on May 26, 2026 at 11:44 pm

    I’m afraid it appears that the answer is no: Unlike some of the other log4net config elements, the appender element’s type attribute does not support parameters.

    As discussed in the comments to your question, since what you are trying to achieve is making a Visual Studio project template that provides its own log4net appender type, a solution would be to make use of the Visual Studio templating system to write the relevant attribute value in the .config file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using log4net for logging my asp.net application. However the log file is
Just started using log4net and trying to get my head around the config and
We are using log4net and want to specify it's configuration in an external config
My application writes a log file (currently using log4net ). I'd like to setup
I'm using XSLT to process my ASP.Net web.config file to insert some extra log4net
I am using log4net and have completely setup it up with param name=File value=
I am using Log4Net with the AdoNetAppender to log messages from a simple systray
I'm using log4net to log write log message to a rolling log file. Now
I am using log4net to log to the console, and the %date conversionPattern value
I am using log4net and in one class require logging to a RollingFile appender,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.