Note that there are some explanatory texts on larger screens.

plurals
  1. POlog4net custom appender not working
    primarykey
    data
    text
    <p>i have create a custom appender using log4net for my project. i created the SampleLogAppender class using AppenderSkeleton interface.</p> <pre><code>namespace Sample.Integrations.Utilities { public class SampleLogAppender : AppenderSkeleton { public static IContext Context { get; set; } protected override void Append(log4net.Core.LoggingEvent loggingEvent) { if (Context != null) { Context.LogMessage(RenderLoggingEvent( loggingEvent )); } } protected override bool RequiresLayout { get { return true; } } } </code></pre> <p>}</p> <p>if i configure this class in config file, it is not working. below configuration i am using.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /&gt; &lt;/configSections&gt; &lt;log4net&gt; &lt;appender name="LogAppender" type="Sample.Integrations.Utilities.SampleLogAppender "&gt; &lt;layout type="log4net.Layout.PatternLayout"&gt; &lt;conversionPattern value="[%date{MM/dd/yyyy hh:mm:ss tt}] [%-5level] [%class]-[%method] - [%message] %newline" /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;logger name="LogRoot"&gt; &lt;level value="ALL" /&gt; &lt;appender-ref ref="LogAppender" /&gt; &lt;/logger&gt; &lt;/log4net&gt; &lt;/configuration&gt; </code></pre> <p>above config file i am using, but it is not working. below i am using the log4net configuration.</p> <pre><code> log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(ConfigLocation)); Log = log4net.LogManager.GetLogger("LogRoot"); </code></pre> <p>i am having Logger class also.</p> <pre><code> public class Logger { public static ILog Log; public static string ConfigLocation = string.Empty; private static readonly string ConversionPattern = "[%date{MM/dd/yyyy hh:mm:ss tt}] [%-5level] [%class]-[%method] - [%message] %newline"; public static void ConfigureLog(IContext context) { SampleLogAppender .Context = context; log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(ConfigLocation)); Log = log4net.LogManager.GetLogger("LogRoot"); } } </code></pre> <p>i initialize Logger like below in startup project.</p> <pre><code>Logger.ConfigureLog(_context); </code></pre> <p>i use the logger like below.</p> <pre><code>Logger.Log.Debug("Test"); </code></pre> <p>when i call this , the Append() method doesn't call.</p> <p>please give some solutions.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload