Reputation: 31
Hi I am using log4net in my windows application following is the content of my app.confige file. there are two tags in my app.confige file i need both of them to work in my appllication. but the problem is that if i include both the tags in that case my logs are not created in the application.log file whereas if i comment runtime and and assemblies tag only then logs are created in the application.log file but as i comment out the runtime and assemblies tag i can not implement other functionalities for the application.
please help to get me the solution.
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin"/>
</assemblyBinding>
</runtime>
<assemblies>
<add assembly="ImageGear19.Core"/>
</assemblies>
<!--The settings below are required for Logging-->
<log4net>
<appender name="Application" type="log4net.Appender.RollingFileAppender">
<file value="Application.log"/>
<appendToFile value="true"/>
<maxSizeRollBackups value="10"/>
<maximumFileSize value="2 MB"/>
<rollingStyle value="Size"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date[%thread](%-5level): %message%newline"/>
</layout>
</appender>
<logger name="Application">
<level value="All"/>
<appender-ref ref="Application"/>
</logger>
</log4net>
Upvotes: 0
Views: 963
Reputation: 1340
The best way to debug log4net would be to enable its internal error logging. This logs everything that it does and helps you trace back to what the issues is.
Here is a similar thread and description on how to enable internal logging in log4net
Add this to your app settings
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
</appSettings>
</configuration>
and add this at the bottom of you web.config
<configuration>
...
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add
name="textWriterTraceListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\temp\log4net.txt" />
</listeners>
</trace>
</system.diagnostics>
...
</configuration>
Upvotes: 1
Reputation:
Personally, there are some errors related to the logics processing first two tags. You are encouraged to debug at the point where log4net is initialized.
Upvotes: 1