<p>How do I make <a href="http://logging.apache.org/log4net/index.html" rel="noreferrer">Log4net</a> only log Info level logs? Is that even possible? Can you only set a threshold? </p>

<p>This is what I have, and it logs Info and above as I would expect. Is there anything i can do to make it only log info?</p>

<pre class="lang-xml prettyprint-override"><code>&lt;logger name="BrokerCollection.Model.XmlDocumentCreationTask"&gt;
  &lt;appender-ref ref="SubmissionAppender"/&gt;
  &lt;level value="Info" /&gt;
&lt;/logger&gt;
</code></pre>

[{'answer_id': 10383, 'author': 'Brandon Wood', 'author_id': 423, 'author_profile': 'https://Stackoverflow.com/users/423', 'pm_score': 8, 'selected': True, 'text': '<p>Within the definition of the appender, I believe you can do something like this:</p>\n\n<pre class="lang-xml prettyprint-override"><code>&lt;appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender"&gt;\n    &lt;filter type="log4net.Filter.LevelRangeFilter"&gt;\n        &lt;param name="LevelMin" value="INFO"/&gt;\n        &lt;param name="LevelMax" value="INFO"/&gt;\n    &lt;/filter&gt;\n    ...\n&lt;/appender&gt;\n</code></pre>\n'}, {'answer_id': 85028, 'author': 'Charley Rathkopf', 'author_id': 10119, 'author_profile': 'https://Stackoverflow.com/users/10119', 'pm_score': 3, 'selected': False, 'text': '<p><strong>Yes.</strong>  It is done with a filter on the appender. </p>\n\n<p>Here is the appender configuration I normally use, limited to only INFO level.</p>\n\n<pre class="lang-xml prettyprint-override"><code>&lt;appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"&gt;\n  &lt;file value="${HOMEDRIVE}\\\\PI.Logging\\\\PI.ECSignage.${COMPUTERNAME}.log" /&gt;\n  &lt;appendToFile value="true" /&gt;\n  &lt;maxSizeRollBackups value="30" /&gt;\n  &lt;maximumFileSize value="5MB" /&gt;\n  &lt;rollingStyle value="Size" /&gt;     &lt;!--A maximum number of backup files when rolling on date/time boundaries is not supported. --&gt;\n  &lt;staticLogFileName value="false" /&gt;\n  &lt;lockingModel type="log4net.Appender.FileAppender+MinimalLock" /&gt;\n  &lt;layout type="log4net.Layout.PatternLayout"&gt;\n        &lt;param name="ConversionPattern" value="%date{yyyy-MM-dd HH:mm:ss.ffff} [%2thread] %-5level %20.20type{1}.%-25method at %-4line| (%-30.30logger) %message%newline" /&gt;\n  &lt;/layout&gt;\n\n  &lt;filter type="log4net.Filter.LevelRangeFilter"&gt;\n        &lt;levelMin value="INFO" /&gt;\n        &lt;levelMax value="INFO" /&gt;\n  &lt;/filter&gt;\n&lt;/appender&gt;    \n</code></pre>\n'}, {'answer_id': 816854, 'author': 'Yordan Georgiev', 'author_id': 65706, 'author_profile': 'https://Stackoverflow.com/users/65706', 'pm_score': 2, 'selected': False, 'text': '<p>If you would like to perform it dynamically try this:</p>\n\n<pre class="lang-cs prettyprint-override"><code>using System;\nusing System.Collections.Generic;\nusing System.Text;\nusing log4net;\nusing log4net.Config;\nusing NUnit.Framework;\n\nnamespace ExampleConsoleApplication\n{\n  enum DebugLevel : int\n  { \n    Fatal_Msgs = 0 , \n    Fatal_Error_Msgs = 1 , \n    Fatal_Error_Warn_Msgs = 2 , \n    Fatal_Error_Warn_Info_Msgs = 3 ,\n    Fatal_Error_Warn_Info_Debug_Msgs = 4 \n  }\n\n  class TestClass\n  {\n    private static readonly ILog logger = LogManager.GetLogger(typeof(TestClass));\n\n    static void Main ( string[] args )\n    {\n      TestClass objTestClass = new TestClass ();\n\n      Console.WriteLine ( " START " );\n\n      int shouldLog = 4; //CHANGE THIS FROM 0 TO 4 integer to check the functionality of the example\n      //0 -- prints only FATAL messages \n      //1 -- prints FATAL and ERROR messages \n      //2 -- prints FATAL , ERROR and WARN messages \n      //3 -- prints FATAL  , ERROR , WARN and INFO messages \n      //4 -- prints FATAL  , ERROR , WARN , INFO and DEBUG messages \n\n      string srtLogLevel = String.Empty; \n      switch (shouldLog)\n      {\n        case (int)DebugLevel.Fatal_Msgs :\n          srtLogLevel = "FATAL";\n          break;\n        case (int)DebugLevel.Fatal_Error_Msgs:\n          srtLogLevel = "ERROR";\n          break;\n        case (int)DebugLevel.Fatal_Error_Warn_Msgs :\n          srtLogLevel = "WARN";\n          break;\n        case (int)DebugLevel.Fatal_Error_Warn_Info_Msgs :\n          srtLogLevel = "INFO"; \n          break;\n        case (int)DebugLevel.Fatal_Error_Warn_Info_Debug_Msgs :\n          srtLogLevel = "DEBUG" ;\n          break ;\n        default:\n          srtLogLevel = "FATAL";\n          break;\n      }\n\n      objTestClass.SetLogingLevel ( srtLogLevel );\n\n\n      objTestClass.LogSomething ();\n\n\n      Console.WriteLine ( " END HIT A KEY TO EXIT " );\n      Console.ReadLine ();\n    } //eof method \n\n    /// &lt;summary&gt;\n    /// Activates debug level \n    /// &lt;/summary&gt;\n    /// &lt;sourceurl&gt;http://geekswithblogs.net/rakker/archive/2007/08/22/114900.aspx&lt;/sourceurl&gt;\n    private void SetLogingLevel ( string strLogLevel )\n    {\n     string strChecker = "WARN_INFO_DEBUG_ERROR_FATAL" ;\n\n      if (String.IsNullOrEmpty ( strLogLevel ) == true || strChecker.Contains ( strLogLevel ) == false)\n        throw new Exception ( " The strLogLevel should be set to WARN , INFO , DEBUG ," );\n\n\n\n      log4net.Repository.ILoggerRepository[] repositories = log4net.LogManager.GetAllRepositories ();\n\n      //Configure all loggers to be at the debug level.\n      foreach (log4net.Repository.ILoggerRepository repository in repositories)\n      {\n        repository.Threshold = repository.LevelMap[ strLogLevel ];\n        log4net.Repository.Hierarchy.Hierarchy hier = (log4net.Repository.Hierarchy.Hierarchy)repository;\n        log4net.Core.ILogger[] loggers = hier.GetCurrentLoggers ();\n        foreach (log4net.Core.ILogger logger in loggers)\n        {\n          ( (log4net.Repository.Hierarchy.Logger)logger ).Level = hier.LevelMap[ strLogLevel ];\n        }\n      }\n\n      //Configure the root logger.\n      log4net.Repository.Hierarchy.Hierarchy h = (log4net.Repository.Hierarchy.Hierarchy)log4net.LogManager.GetRepository ();\n      log4net.Repository.Hierarchy.Logger rootLogger = h.Root;\n      rootLogger.Level = h.LevelMap[ strLogLevel ];\n    }\n\n    private void LogSomething ()\n    {\n      #region LoggerUsage\n      DOMConfigurator.Configure (); //tis configures the logger \n      logger.Debug ( "Here is a debug log." );\n      logger.Info ( "... and an Info log." );\n      logger.Warn ( "... and a warning." );\n      logger.Error ( "... and an error." );\n      logger.Fatal ( "... and a fatal error." );\n      #endregion LoggerUsage\n\n    }\n  } //eof class \n} //eof namespace \n</code></pre>\n\n<p>The app config:</p>\n\n<pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;\n&lt;configuration&gt;\n    &lt;configSections&gt;\n        &lt;section name="log4net"\n                 type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /&gt;\n    &lt;/configSections&gt;\n    &lt;log4net&gt;\n        &lt;appender name="LogFileAppender" type="log4net.Appender.FileAppender"&gt;\n            &lt;param name="File" value="LogTest2.txt" /&gt;\n            &lt;param name="AppendToFile" value="true" /&gt;\n            &lt;layout type="log4net.Layout.PatternLayout"&gt;\n                &lt;param name="Header" value="[Header] \\r\\n" /&gt;\n                &lt;param name="Footer" value="[Footer] \\r\\n" /&gt;\n                &lt;param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" /&gt;\n            &lt;/layout&gt;\n        &lt;/appender&gt;\n\n        &lt;appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender"&gt;\n            &lt;mapping&gt;\n                &lt;level value="ERROR" /&gt;\n                &lt;foreColor value="White" /&gt;\n                &lt;backColor value="Red, HighIntensity" /&gt;\n            &lt;/mapping&gt;\n            &lt;layout type="log4net.Layout.PatternLayout"&gt;\n                &lt;conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /&gt;\n            &lt;/layout&gt;\n        &lt;/appender&gt;\n\n\n        &lt;appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender"&gt;\n            &lt;connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.2.10.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /&gt;\n            &lt;connectionString value="data source=ysg;initial catalog=DBGA_DEV;integrated security=true;persist security info=True;" /&gt;\n            &lt;commandText value="INSERT INTO [DBGA_DEV].[ga].[tb_Data_Log] ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message)" /&gt;\n\n            &lt;parameter&gt;\n                &lt;parameterName value="@log_date" /&gt;\n                &lt;dbType value="DateTime" /&gt;\n                &lt;layout type="log4net.Layout.PatternLayout" value="%date{yyyy\'-\'MM\'-\'dd HH\':\'mm\':\'ss\'.\'fff}" /&gt;\n            &lt;/parameter&gt;\n            &lt;parameter&gt;\n                &lt;parameterName value="@thread" /&gt;\n                &lt;dbType value="String" /&gt;\n                &lt;size value="255" /&gt;\n                &lt;layout type="log4net.Layout.PatternLayout" value="%thread" /&gt;\n            &lt;/parameter&gt;\n            &lt;parameter&gt;\n                &lt;parameterName value="@log_level" /&gt;\n                &lt;dbType value="String" /&gt;\n                &lt;size value="50" /&gt;\n                &lt;layout type="log4net.Layout.PatternLayout" value="%level" /&gt;\n            &lt;/parameter&gt;\n            &lt;parameter&gt;\n                &lt;parameterName value="@logger" /&gt;\n                &lt;dbType value="String" /&gt;\n                &lt;size value="255" /&gt;\n                &lt;layout type="log4net.Layout.PatternLayout" value="%logger" /&gt;\n            &lt;/parameter&gt;\n            &lt;parameter&gt;\n                &lt;parameterName value="@message" /&gt;\n                &lt;dbType value="String" /&gt;\n                &lt;size value="4000" /&gt;\n                &lt;layout type="log4net.Layout.PatternLayout" value="%messag2e" /&gt;\n            &lt;/parameter&gt;\n        &lt;/appender&gt;\n        &lt;root&gt;\n            &lt;level value="INFO" /&gt;\n            &lt;appender-ref ref="LogFileAppender" /&gt;\n            &lt;appender-ref ref="AdoNetAppender" /&gt;\n            &lt;appender-ref ref="ColoredConsoleAppender" /&gt;\n        &lt;/root&gt;\n    &lt;/log4net&gt;\n&lt;/configuration&gt;\n</code></pre>\n\n<p>The references in the csproj file:</p>\n\n<pre class="lang-xml prettyprint-override"><code>&lt;Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL"&gt;\n  &lt;SpecificVersion&gt;False&lt;/SpecificVersion&gt;\n  &lt;HintPath&gt;..\\..\\..\\Log4Net\\log4net-1.2.10\\bin\\net\\2.0\\release\\log4net.dll&lt;/HintPath&gt;\n&lt;/Reference&gt;\n&lt;Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" /&gt;\n</code></pre>\n'}, {'answer_id': 6879650, 'author': 'Javier Sanchez', 'author_id': 185766, 'author_profile': 'https://Stackoverflow.com/users/185766', 'pm_score': 5, 'selected': False, 'text': '<p>Use <code>threshold</code>.</p>\n\n<p>For example:</p>\n\n<pre class="lang-xml prettyprint-override"><code>   &lt;appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"&gt;\n        &lt;threshold value="WARN"/&gt;\n        &lt;param name="File" value="File.log" /&gt;\n        &lt;param name="AppendToFile" value="true" /&gt;\n        &lt;param name="RollingStyle" value="Size" /&gt;\n        &lt;param name="MaxSizeRollBackups" value="10" /&gt;\n        &lt;param name="MaximumFileSize" value="1024KB" /&gt;\n        &lt;param name="StaticLogFileName" value="true" /&gt;\n        &lt;layout type="log4net.Layout.PatternLayout"&gt;\n            &lt;param name="Header" value="[Server startup]&amp;#13;&amp;#10;" /&gt;\n            &lt;param name="Footer" value="[Server shutdown]&amp;#13;&amp;#10;" /&gt;\n            &lt;param name="ConversionPattern" value="%d %m%n" /&gt;\n        &lt;/layout&gt;\n    &lt;/appender&gt;\n    &lt;appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" &gt;\n        &lt;threshold value="ERROR"/&gt;\n        &lt;layout type="log4net.Layout.PatternLayout"&gt;\n            &lt;conversionPattern value="%date [%thread]- %message%newline" /&gt;\n        &lt;/layout&gt;\n    &lt;/appender&gt;\n    &lt;appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"&gt;\n        &lt;threshold value="INFO"/&gt;\n        &lt;layout type="log4net.Layout.PatternLayout"&gt;\n            &lt;param name="ConversionPattern" value="%d [%thread] %m%n" /&gt;\n        &lt;/layout&gt;\n    &lt;/appender&gt;\n</code></pre>\n\n<p>In this example all INFO and above are sent to Console, all WARN are sent to file and ERRORs are sent to the Event-Log.</p>\n'}, {'answer_id': 47055940, 'author': 'Sarfaraaz', 'author_id': 4801298, 'author_profile': 'https://Stackoverflow.com/users/4801298', 'pm_score': 1, 'selected': False, 'text': '<p>you can use log4net.Filter.LevelMatchFilter.\nother options can be found at\n<a href="http://www.beefycode.com/post/log4net-tutorial-pt-7-filters.aspx" rel="nofollow noreferrer">log4net tutorial - filters</a></p>\n\n<p>in ur appender section add</p>\n\n<pre class="lang-xml prettyprint-override"><code>&lt;filter type="log4net.Filter.LevelMatchFilter"&gt;\n    &lt;levelToMatch value="Info" /&gt;\n    &lt;acceptOnMatch value="true" /&gt;\n&lt;/filter&gt;\n</code></pre>\n\n<p>the accept on match default is true so u can leave it out but if u set it to false u can filter out log4net filters</p>\n'}]
['https://Stackoverflow.com/questions/6007', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/230/']