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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:05:35+00:00 2026-05-28T08:05:35+00:00

Ok, so I’m understood how to configure the log4Net in my application, But now

  • 0

Ok, so I’m understood how to configure the log4Net in my application, But now

First I want to improve the configuration by differencing the level of the logs if the application it’s a release or a debug, how can I do this?.

Second, If I had a folder in my project called LOG how can I set the configuration, to not used the physical folder of my application??

for example Instead of:

<file value="C:\physicalpath\LOG\Log.log" /> 

used

<file value="\LOG\Log.log" /> 

or

<file value="%some_variable%\LOG\Log.log" /> 
  • 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-28T08:05:35+00:00Added an answer on May 28, 2026 at 8:05 am

    The documenation is straight forward:

    file: the full or relative path to the log file.

    So all you need to have is the full path like C:\physicalpath\LOG\Log.log or the ralative one, this needs to start with the dot char . like .\App_Data\Log4Net.Logs

    you can also use the folder name in the file attribute, then you must use the datePattern attribute to specify the file name, for example:

    <appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
      <file value=".\\App_Data\\Log4Net.Logs\\backend"/>
      <datePattern value=".yyyy-MM-dd'.log'"/>
      <appendToFile value="true"/>
      <maximumFileSize value="256KB"/>
      <maxSizeRollBackups value="2"/>
      <rollingStyle value="Date"/>
      <staticLogFileName value="false"/>
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
      <layout type="log4net.Layout.PatternLayout">
         <conversionPattern value="%level %thread %logger - %message%newline"/>
      </layout>
    </appender>
    

    Also remember to add the

    <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
    

    So you can avoid that log4net lock the file and you can’t used it to append your messages.

    If you’re not used to log4net, don’t forget to add the <root> node, this is the the one that let’s log4net know what you want to use and not the <appender> nodes, for example, you can have 10 <appender> nodes and use only one, the <root> node is then only configured with the one you want to use…


    here is a full configuration with 2 Mongo Appenders and 1 File Appender, the <root> specifies that only the file appender is in use:

      <log4net>
        <appender name="MongoAppender" type="log4net.Appender.MongoDBAppender, log4mongo-net">
          <!-- MongoDB 1 connection options -->
          <host value="staff.mongohq.com"/>
          <port value="10077"/>
          <databaseName value="myApp_2011"/>
          <collectionName value="logs_net"/>
          <userName value="myself"/>
          <password value="123456"/>
        </appender>
        <appender name="MongoAppenderAppHarbor" type="log4net.Appender.MongoDBAppender, log4mongo-net">
          <!-- MongoDB 2 connection options -->
          <host value="staff.mongohq.com"/>
          <port value="10048"/>
          <databaseName value="d1741d63-46b1-4a44-9c49-8c28cecae36b"/>
          <collectionName value="logs_net"/>
          <userName value="myself"/>
          <password value="123456"/>
        </appender>
        <appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
          <!-- Local file options -->
          <file value=".\\App_Data\\Log4Net.Logs\\backend"/>
          <datePattern value=".yyyy-MM-dd'.log'"/>
          <appendToFile value="true"/>
          <maximumFileSize value="256KB"/>
          <maxSizeRollBackups value="2"/>
          <rollingStyle value="Date"/>
          <staticLogFileName value="false"/>
          <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
          <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%level %thread %logger - %message%newline"/>
          </layout>
        </appender>
        <root>
          <!--
             <level value="DEBUG" />
             <appender-ref ref="MongoAppender" />
             <appender-ref ref="MongoAppenderAppHarbor" />
          -->
          <appender-ref ref="FileAppender"/>
        </root>
      </log4net>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I'm interested in microtypography issues on the web. I want a tool to fix:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.