mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#18011: Avoiding multiple XmlConfigurator.ConfigureAndWatch (and resulting file monitors) calls.
--HG-- branch : 1.x
This commit is contained in:
@@ -5,7 +5,6 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using Autofac;
|
||||
using Autofac.Core;
|
||||
using Castle.Services.Logging.Log4netIntegration;
|
||||
using Module = Autofac.Module;
|
||||
|
||||
namespace Orchard.Logging {
|
||||
|
@@ -7,13 +7,16 @@ using Orchard.Environment;
|
||||
|
||||
namespace Orchard.Logging {
|
||||
public class OrchardLog4netFactory : AbstractLoggerFactory {
|
||||
private static bool _isFileWatched = false;
|
||||
|
||||
public OrchardLog4netFactory(IHostEnvironment hostEnvironment)
|
||||
: this(ConfigurationManager.AppSettings["log4net.Config"], hostEnvironment) { }
|
||||
|
||||
public OrchardLog4netFactory(string configFilename, IHostEnvironment hostEnvironment) {
|
||||
if (!string.IsNullOrWhiteSpace(configFilename) && hostEnvironment.IsFullTrust) {
|
||||
if (!_isFileWatched && !string.IsNullOrWhiteSpace(configFilename) && hostEnvironment.IsFullTrust) {
|
||||
// Only monitor configuration file in full trust
|
||||
XmlConfigurator.ConfigureAndWatch(GetConfigFile(configFilename));
|
||||
_isFileWatched = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user