mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +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 System.Reflection;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Core;
|
using Autofac.Core;
|
||||||
using Castle.Services.Logging.Log4netIntegration;
|
|
||||||
using Module = Autofac.Module;
|
using Module = Autofac.Module;
|
||||||
|
|
||||||
namespace Orchard.Logging {
|
namespace Orchard.Logging {
|
||||||
|
|||||||
@@ -7,13 +7,16 @@ using Orchard.Environment;
|
|||||||
|
|
||||||
namespace Orchard.Logging {
|
namespace Orchard.Logging {
|
||||||
public class OrchardLog4netFactory : AbstractLoggerFactory {
|
public class OrchardLog4netFactory : AbstractLoggerFactory {
|
||||||
|
private static bool _isFileWatched = false;
|
||||||
|
|
||||||
public OrchardLog4netFactory(IHostEnvironment hostEnvironment)
|
public OrchardLog4netFactory(IHostEnvironment hostEnvironment)
|
||||||
: this(ConfigurationManager.AppSettings["log4net.Config"], hostEnvironment) { }
|
: this(ConfigurationManager.AppSettings["log4net.Config"], hostEnvironment) { }
|
||||||
|
|
||||||
public OrchardLog4netFactory(string configFilename, IHostEnvironment 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
|
// Only monitor configuration file in full trust
|
||||||
XmlConfigurator.ConfigureAndWatch(GetConfigFile(configFilename));
|
XmlConfigurator.ConfigureAndWatch(GetConfigFile(configFilename));
|
||||||
|
_isFileWatched = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user