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, Denisa *.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" />* * </layout>* * <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>* * </appender>* * <!-- 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" />* * </layout>* * <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>* * </appender>* In *Global.asax.cs* > *Application_Start()* I have defined the subdomain and calling the log4net config *GlobalContext.Properties["subdomain"] = new DeferredHttpContextValueProvider("Subdomain");* *XmlConfigurator.Configure();*