Gjorven, Oyvind | 16 May 18:42 2016

Setting backColor on ColoredConsoleAppender at runtime...

Is it possible to use the GlobalContext to set the backColor property of the ColoredConsoleAppender at runtime?


I have this mapping in the log4net.xml file:

Michal | 11 May 16:47 2016

Sometimes missing log entries

I am using log4net version as Nuget and sometimes I miss some log entries.
I am loading .net functions via pythonnet, but it looks like it entres to the function and sometimes there are missing some logs.
So I enabled internal debug logging.
There is a code what I have:
logger.Info("reading def"); string textDefinition = FileExtensions.ReadAllTextReadOnly(testPath); logger.Info("Definition"); logger.Debug(textDefinition); try { testDefinition = JsonConvert.DeserializeObject<TestSuiteDefinition>(textDefinition); } catch (Exception e) { logger.Info("failed reload def"); logger.Info(e.Message); } logger.Info("test 1");
And this is what I have logged, but just sometimes, in most of all cases it logs everything.
2016-05-10T18:33:50 reading def 2016-05-10T18:33:50 Definition 2016-05-10T18:33:50 { very long JSON... } After some time logging continues.
I uploaded log4net internal debug log: http://textuploader.com/5btua, but I have nothing susspicious found.
Could you please help me what to do to determine problem why there are missing some logs?
It is happening on 7x64 and also on Mac OS Yosemite with mono.
Denisa Bokar | 5 May 19:21 2016

Fwd: logging in separate file in a multi-tenant application

Hi all, 

I have a multi-tenant application on which I'm using log4net. Until now, I have had all clients logging into 2 separate files split by 'threshold value="Error"' (errors and everything else). The appenders are of type RollingFileAppender (I have included below the appenders).

What I am trying to achieve is that each that each thread (tenant) to write to its individual files (tenant1_errors & tenant1_everything_else) - ideally, without having to manually specify the tenants.

I found this: http://www.developersalley.com/blog/post/2012/02/09/How-To-Write-To-Seperate-Log-Files-During-Multi-Threaded-Processing-Using-Log4Net-PropertyFilters.aspx as a great example, however I do not want to move the appender definition in C# code - I would like to keep it in the .config file. 

I am considering making a template and generating appenders for each tenant (based on the template) and including them in the .config file.

Has anyone encountered this scenario before? Any advice on best way to tackle this is more than welcome.

Thank you,

.config appenders:
 <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" value=".\App_Data\logs\quest.log" />
      <appendToFile value="true" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="10MB"/>
      <rollingStyle value="Size"/>
      <countDirection value="1" />
      <!-- so older files aren't subsequently renamed. helps with log shipping so filenames don't change -->
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%utcdate{yyyy-MM-dd HH:mm:ss.fff} UTC %-5level %property{subdomain} [%thread] %logger{1} %property{username} %message %exception%newline" />
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>

    <!-- Separate error file -->
    <appender name="ErrorFile" type="log4net.Appender.RollingFileAppender">
      <threshold value="Error" />
      <file  type="log4net.Util.PatternString" value=".\App_Data\logs\quest_error.log" />
      <appendToFile value="true" />
      <maxSizeRollBackups value="3" />
      <maximumFileSize value="10MB"/>
      <rollingStyle value="Size"/>
      <countDirection value="1" />
      <!-- so older files aren't subsequently renamed. helps with log shipping so filenames don't change -->
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%utcdate{yyyy-MM-dd HH:mm:ss.fff} UTC %-5level %property{subdomain} [%thread] %logger{1} %property{username} %message %exception%newline" />
      <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>

In Global.asax.cs > Application_Start() I  have defined the subdomain and calling the log4net config
 GlobalContext.Properties["subdomain"] = new DeferredHttpContextValueProvider("Subdomain");

Justin Taylor | 5 Apr 22:18 2016

Adjust log4net logging severity

I’m working on a .NET Windows app, and I need the ability for the user to change the logging severity from within the app.  Right now, I have the logging severity set in my .config file, but that lives under Program Files so the user can’t modify that file.    I looked at the ConfigFile attribute and the <appSettings> keys to move the location of the configuration file.  I have Terminal Server users, so I’d really need to put the config somewhere user specific.  I think under %appData% would be best, but I can’t get the ConfigFile attribute or <appSettings> to work with that.


Is there a way to point the config to %appData%?  Is there a better way to change logging severity?




Nicholas Duane | 26 Mar 02:09 2016

Failing to log in release build

I think I might be running into the problem defined by this post:


Here's the setup.  We've created a client framework which exposes some event creation methods.  We expect those methods to get called in order to generate events.  Then the application calls log4net to log the event.  I was just debugging some issue where events weren't being logged.  We couldn't figure out what was going on.  Everything seemed to be setup correctly yet no events were flowing.  Almost as if they were being filtered out.  I turned on debug and noticed a difference between when the events weren't being logged and when they were.  When the events did get logged I noticed the following entry in the debug output:

log4net: Creating repository for assembly [...]

This line was missing in the debug output when the events weren't getting logged.

The application is a console application.  The first thing it does in Main() is:


The application explicitly links with our client framework.  Our client framework has the following helper class:

public static class CustomLevels
    public static readonly Level Compliance = LogManager.GetRepository().LevelMap["COMPLIANCE"];

public static class Logging
    public static void Compliance(this ILog logger, object o)
        logger.Logger.Log(null, CustomLevels.Compliance, o, null);

So I was wondering if maybe the Compliance static readonly field was getting initialized before XmlConfigurator.Configure() was called and thus the Compliance Level was not correct.  This would cause the behavior we experience where nothing was getting logged because we have a filter on our appender to filter out everything but compliance level.

Our application config file has the compliance level defined as follows:

        <name value="COMPLIANCE"/>
        <value value="140000"/>

Andreas Tscharner | 22 Mar 11:34 2016

Logger without and derived logger with filter

Hello World,

I am trying to create a logger without and a derived logger with a filter.
Unfortunately this does not work. What I did:

  ILog mainLogger = LogManager.GetLogger("log4net-test");
  ILog classLogger = LogManager.GetLogger("log4net-test.MainClass");

  LogTestManager ltm = new LogTestManager();

  RollingFileAppender rotateAppender = ltm.CreateRollingFileAppender();


  RollingFileAppender rfa = ltm.CreateRollingFileAppender();
  StringMatchFilter smf = ltm.CreateStringMatchFilter("TestMatch");


((log4net.Repository.Hierarchy.Logger)mainLogger.Logger).Level = Level.All;
  ((Hierarchy)LogManager.GetRepository()).Configured = true;

  var firstClass = new MainClass(classLogger);

The first logger ("mainLogger") should log everything (that works), the 
second logger ("classLogger") should log everything (to the same file) 
except text that contains "TestMatch". Unfortunately if I execute:

  mainLogger.Error("An unfiltered TestMatch statement");
  firstClass.PrintLoggingStatement("A filtered TestMatch statement", 

I got both in my log file. If I add the filter to the first 
logger/appender, both statements are filtered.

What I am doing wrong? How to fix this?

TIA and best regards

        `o_ o  )   `-.  (     ).`-.__.`)
        (_Y_.)'  ._   )  `._ `. ``-..-'
      _..`--'_..-_/  /--'_.' .'
     (il).-''  (li).'  ((!.-'

Andreas Tscharner   andy <at> vis.ethz.ch   ICQ-No. 14356454

Kinnar | 14 Mar 13:01 2016

Rolling File Operation : Failing with Source does not exist

Hi All,

We are using log4net in our multi threaded windows service since last 3
years or so.  We have recently encountered that our device became
unresponsive/went into hanging state couple of time. While analyzing crash
dump of the service of that time, we have encountered that one of our thread
has failed during rolling file operation. The stack trace of failed thread
as follows :
  log4net.Util.LogLog.Warn(System.Type, System.String) 

While going through error thrown by above stack trace, we have encountered
following error message :
  log4net:WARN Cannot RollFile [....] -> [....]. Source does not exist

All other threads are waiting at following log4net method :


Rolling File Pattern is as following :
    <datePattern value=".yyyyMMdd-HH&quot;.log&quot;"/>

We are not able to understand what is exactly wrong over here which causes
service to become unresponsive. Does rolling file operation cause the
thread, which is using it, to go into unresponsive state if some error
occurs ? We have gone through other posts which are telling to use different
datepattern but changing datepattern is not solving problem for everybody.
We would like to know what is the full proof way to solve this issue. 


View this message in context: http://apache-logging.6191.n7.nabble.com/Rolling-File-Operation-Failing-with-Source-does-not-exist-tp62802.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Shivinder Singh | 7 Mar 16:30 2016

aspnetrequest server variables' values

How/where can I get the values of server variables logged by the aspnet-request conversion pattern?

This is what I'm getting currently for my ASP.NET MVC application.

Melissa Warnkin | 11 Feb 19:23 2016

ApacheCon NA 2016 - Important Dates!!!

Hello everyone!

I hope this email finds you well.  I hope everyone is as excited about ApacheCon as I am!

I'd like to remind you all of a couple of important dates, as well as ask for your assistance in spreading the word! Please use your social media platform(s) to get the word out! The more visibility, the better ApacheCon will be for all!! :)

CFP Close: February 12, 2016
CFP Notifications: February 29, 2016
Schedule Announced: March 3, 2016

Apache: Big Data North America 2016 Registration Fees:

Attendee Registration Fee: US$599 through March 6, US$799 through April 10, US$999 thereafter
Committer Registration Fee: US$275 through April 10, US$375 thereafter
Student Registration Fee: US$275 through April 10, $375 thereafter

Planning to attend ApacheCon North America 2016 May 11 - 13, 2016? There is an add-on option on the registration form to join the conference for a discounted fee of US$399, available only to Apache: Big Data North America attendees.

So, please tweet away!!

I look forward to seeing you in Vancouver! Have a groovy day!!

on behalf of the ApacheCon Team

UniqueDisplayName | 25 Jan 21:54 2016

Encrypt connection string in Log4Net configuration

I am trying to encrypt the log4net section to hide the username and password
in the connection string. To do this I'm using .Net's implementation of
encrypting the config file. The code is as follows:

Configuration config = WebConfigurationManager.OpenWebConfiguration("~/");
ConfigurationSection section = config.GetSection("log4net");
if (!section.SectionInformation.IsProtected)


The same approach can be seen in this post:
The beauty of this approach is that your application will decrypt the config
file at runtime, but for some reason this doesn't seem to be working with
log4net. It works fine with other 3rd parties such as Entity Framework. I'm
hoping I can get some advice on getting this to work. It feels like it's an
issue with log4net grabbing the config file before .Net has a chance to
decrypt it but I'm not quite sure how to fix it. Any advice would be great.

FWIW, this is an MVC site using .Net 4.5 and log4net 2.0.5.

Thank You,

View this message in context: http://apache-logging.6191.n7.nabble.com/Encrypt-connection-string-in-Log4Net-configuration-tp61227.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

superfreak3 | 6 Jan 03:01 2016

Re: Using Log4Net with Selenium

I noticed something strange that has happened since adding logging with
log4Net.  When exceptions occur, they are caught and written as desired to
the log.  However, running via both mstest and Visual Studio 2015, despite
the fact exceptions occur, the tests are still seen as successful.

I verified it has something to do with the logging additions as I got the
previous version from TFS and I'm able to run the tests in Visual Studio
where the problematic tests do indicate failure.

I've attached a file that shows the steps I followed to get logging to work. 
I'm not sure if the addition of an app.config file causes this to be handled
differently within the testing framework or handling in Visual Studio.

Any help would be greatly appreciated!!


View this message in context: http://apache-logging.6191.n7.nabble.com/Using-Log4Net-with-Selenium-tp59639p60848.html
Sent from the Log4net - Users mailing list archive at Nabble.com.