Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I use the framework log4net for write the logFile for my application C#.

I want to set manually the path and the size of the file.log in log.config.

My log.config file is :

  <?xml version="1.0" encoding="utf-8" ?>
       <!-- Xml file that contains the configuration of Log4net -->
       <configuration>
       <configSections>
       <section name="log4net" type="System.Configuration.IgnoreSectionHandler"/>
       </configSections>
       <log4net>
       <!-- RollingFileAppender : Writing events to a file. Ability to log on multiple files  based on date and time. -->
      <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
          <file value="C:\...\x.log" />
          <appendToFile value="true" />
          <rollingStyle value="Size" />
          <maxSizeRollBackups value="10" />
          <maximumFileSize value="1MB" />
          <staticLogFileName value="true" />
          <layout type="log4net.Layout.PatternLayout">
             <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
          </layout>
     </appender>
      <!-- We define the root logger to DEBUG level and is associated with the  RollingFileAppender appender -->
    <root>
        <level value="DEBUG" />
        <!-- <appender-ref ref="ConsoleAppender" /> -->
        <appender-ref ref="RollingFileAppender" />
    </root>
</log4net>


Can you help me how to put the path
<file value="C:\...\x.log" />
and the size
<maximumFileSize value="1MB" />
of file.log from my Form C# ?

Thank you in advance.
Posted

1 solution

 
Share this answer
 
Comments
Member 10872485 1-Aug-14 7:31am    
Thank you :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900