简体   繁体   English

log4net'not working' - 在子目录中配置

[英]log4net 'not working' - Configuration in subdirectory

My log4net configuration is stored in a config file located in a subdirectory of the application root. 我的log4net配置存储在位于应用程序根目录的子目录中的配置文件中。

Config\logging.config

The file is marked as an application content with attribute "Copy Always". 该文件被标记为具有“始终复制”属性的应用程序内容。 Additionaly, in my AssemblyInfo.cs, I've declared the following line: 另外,在我的AssemblyInfo.cs中,我已经声明了以下行:

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Config\\logging.config", Watch = true)]

However, log4net doesn't log anything and it doesn't look like its initialized. 但是,log4net不记录任何内容,它看起来不像它的初始化。 How can I tell log4net where my configuration file is so it can initialize its components correctly? 如何告诉log4net我的配置文件在哪里可以正确初始化其组件?

Log4Net is designed to fail silently, on the grounds that no logging is preferable to taking down the application. Log4Net旨在无声地失败,理由是没有日志记录优先于取消应用程序。

Most problems with log4net are (in my experience) related to file and permissions issues. log4net的大多数问题(根据我的经验)与文件和权限问题有关。

  • Does the account under which your app runs have read access to the entire path to the config file? 运行应用程序的帐户是否具有对配置文件的完整路径的读取权限?

  • Is the "current working directory" what you think it is at the time the log4net config file is loaded? 在加载log4net配置文件时,您认为它是“当前工作目录”吗?

To find out what the underlying problem is, use log4net's internall debugging: 要找出底层问题是什么,请使用log4net的内部调试:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM