I want add new log to file.this is my appender:
You need to initialise the logging as the very first step in your app, and from the same assembly that you have the [assembly]
tag:
From the docs:
Therefore if you use configuration attributes you must invoke log4net to allow it to read the attributes. A simple call to
LogManager.GetLogger
will cause the attributes on the calling assembly to be read and processed. Therefore it is imperative to make a logging call as early as possible during the application start-up, and certainly before any external assemblies have been loaded and invoked.
Add something like this in your start up code:
LogManager.GetLogger("Initialises logging from assembly attributes");
Log4net fails silently when there's a problem. The design conceit is that no logging is preferable to taking down the application. To figure out what's wrong, turn on Log4net's internal debugging by adding this key to your [app/web].config file:
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
</appSettings>
The debug messages will be written to the console or to the System.Diagnostics.Trace
system. More details from Phill Haack at http://haacked.com/archive/2006/09/26/Log4Net_Troubleshooting.aspx/
There are any number of reasons Log4net might fail. Permissions problems on the log file directory, for starters (especially true for server processes, where your likely running under a restricted set of permissions for security).
You should add this config section:
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
to refer the log4net configuration.
You just need to call Configure:
log4net.Config.XmlConfigurator.Configure();
You can see more details here: Log4net does not write the log file