Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have configure log4net with a console application successfully .

But after building and taking the dll with supportive files of log4net and app.config file and place it in a new project

if i run that new project log is not working but the other concept in that dll works fine

i do not know where i commited mistake

Can u help me regarding that error

Waiting for your response

my app config generated is

XML
<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
  </configSections>
  <log4net>
    <!--
  This writes the log information to the console window.  It only logs events
  that are at least at the INFO level (which would mean that DEBUG events are not
  captured.
  -->
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date{ABSOLUTE} [%thread] %level %logger - %message%newlineExtra Info: %property{testProperty}%newline%exception"/>
      </layout>
      <filter type="log4net.Filter.LevelRangeFilter">
        <levelMin value="INFO"/>
        <levelMax value="FATAL"/>
      </filter>
    </appender>
    <!--
  This stores information in the mylogfile.txt file.  It only captures log events
  that contain the key word test or error.
  -->
    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="mylogfiles.txt"/>
      <appendToFile value="true"/>
      <rollingStyle value="Size"/>
      <maxSizeRollBackups value="5"/>
      <maximumFileSize value="10MB"/>
      <staticLogFileName value="true"/>

      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %level %logger - %message%newline%exception"/>
      </layout>
    </appender>
    <root>
      <level value="INFO"/>
      <appender-ref ref="RollingFileAppender"/>
    </root>
    <logger name="Log4NetTest.OtherClass">
      <level value="INFO"/>
      <appender-ref ref="ConsoleAppender"/>
    </logger>
  </log4net>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>



Regards
Gowtham
Posted
Updated 17-May-12 1:37am
v3
Comments
Pete O'Hanlon 17-May-12 7:34am    
Please edit your question and post your app.config file.
gowthammanju 17-May-12 7:38am    
i updated the build app config file.Can u provide me some reference files links where i get the solution if possible

1 solution

If I understand you correctly, you tested everything out in one application and then put the config and the dll into a new application and now nothing works. It sounds to me like you might not have done all of the work in your code that you need to do. For example, did you set up your GetLogger variable correctly? Are you actually making any calls to the logger?

I'm really not a fan of trying to copy a whole config. Instead, I would rather see you copy just the log4net portion that you need. Otherwise, you can easily introduce issues.

I wrote an aricle about a year ago that walks you through log4net step by step and explains each step. Maybe if you walk through each step and compare it against your non-working application, you will see where the trouble is. Here is the link to the article:

log4net Tutorial[^]
 
Share this answer
 

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