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 3286178
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:21:02+00:00 2026-05-17T20:21:02+00:00

I am trying to configure a dynamic name for my log but i can’t:

  • 0

I am trying to configure a dynamic name for my log but i can’t:

Here is the code in my web.config file:

<appender name="RollingFile" type="log4net.Appender.RollingPatternFileAppender">
  <file type="log4net.Util.PatternString" value="..l\log\%property{LogName}" />
  <appendToFile value="true" />
  <rollingStyle value="Size" />
  <maxSizeRollBackups value="-1" />
  <maximumFileSize value="5000KB" />
  <staticLogFileName value="true" />
  <countDirection value="1"/>
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%m%n" />
  </layout>
  <filter type="log4net.Filter.PropertyFilter">
    <Key value="Version" />
    <StringToMatch value="1" />

  </filter>
  <filter type="log4net.Filter.DenyAllFilter" />

  <root>
    <level value="DEBUG"/>
    <appender-ref ref="RollingFile"/>
  </root>

</appender>
<logger name="File">
  <level value="All" />
  <appender-ref ref="RollingFile" />
</logger>

Here is the global.asax:

log4net.Config.XmlConfigurator.Configure();

The codebehind:

log = LogManager.GetLogger(
            System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
log4net.ThreadContext.Properties["LogName"] = 
            sito + "_Truck_Log_" + DateTime.Today.ToString("dd-MM-yyyy") + ".txt";

This does not create any log files? Why would this be?

Update 1:

I have moved log4net.Config.XmlConfigurator.Configure(); after the set thread context property but still at not work anyway.

Update 2:

@sgmoore: I am sure that I don’t have permissions problems and I am sure that the “sito” variable does not contain invalid characters. I am doing something like this:

In my codebehind:

log4net.GlobalContext.Properties["LogName"] = 
           sito + "_Truck_Log_" + DateTime.Today.ToString("dd-MM-yyyy")+".txt";
log = LogManager.GetLogger(
           System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

In global.asax:

void Application_Start(object sender, EventArgs e) 
{
     log4net.Config.XmlConfigurator.ConfigureAndWatch(
          new System.IO.FileInfo(
            AppDomain.CurrentDomain.SetupInformation.ApplicationBase 
                                                       + "log4net.config")); 
}

But this still won’t work.

  • 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-17T20:21:03+00:00Added an answer on May 17, 2026 at 8:21 pm

    You have to set the thread context property before you configure log4net.

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

Sidebar

Related Questions

I'm trying configure AzMan but I Have got problem with code. Can you explain
I'm trying to configure a web application that can use client-side JavaScript for localization
Trying to configure Zend_Cache_Backend_Memcached via a config.ini or config.xml file. I'm not sure how
I'm trying to configure connection pool in Tomcat 7. Here is code: part of
I am trying to configure an apache server using mod_wsgi for dynamic mass hosting.
I've been trying to configure the new Facebook Javascript API with my website, but
I'm trying to configure distributed search in Solr 1.4. It can work perfectly by
After trying to search for some information about Dynamic change of changelog.txt file with
I'm trying to configure IIS to parse a .xml file just like it would
Trying to configure spring 3 MVC, here is what I did so far: I

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.