log4net控制台应用程序未登录发布

编程入门 行业动态 更新时间:2024-10-24 21:30:19
本文介绍了log4net控制台应用程序未登录发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个使用log4net的控制台应用程序(通过Castle Windsor).调试时,一切都正常记录到控制台,但是当我发布并运行该应用程序时,没有任何记录.

I have a console app using log4net (via Castle Windsor). Everything logs fine to the console when I debug, but when I publish and run the app, nothing is logged.

我的log4net配置位于单独的文件(log4net.config)中. 我在想找不到配置文件,但这只是一个猜测.

I have my log4net configuration in a separate file (log4net.config). I'm thinking it's not finding the config file, but that's just a guess.

我是网络开发人员,还没有部署很多控制台应用程序.我想念什么吗? 我需要手动将log4net.config文件复制到exe目录吗?

I'm a web dev and haven't deployed many console apps. Am I missing something? Do I need to manually copy the log4net.config file to the exe directory?

我正在使用VS2010.

I'm on VS2010.

app.config:

<?xml version="1.0"?> <configuration> <configSections> <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor"/> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false"/> </configSections> <appSettings> ... <add key="log4net.Internal.Debug" value="false"/> </appSettings> <startup> <supportedRuntime version="v2.0.50727"/></startup> <castle> <components> ... </components> <facilities> <facility id="loggingfacility" configfile="log4net.config" loggingapi="log4net" type="Castle.Facilities.Logging.LoggingFacility, Castle.Facilities.Logging"/> </facilities> </castle> </configuration>

log4net.config:

<?xml version="1.0" encoding="utf-8" ?> <configuration> <log4net> <root> <!-- Value of priority may be ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF --> <priority value="ALL" /> <appender-ref ref="ConsoleAppender" /> </root> <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%d: [%-5p] %m%n" /> </layout> </appender> <logger name="Castle"> <level value="INFO" /> </logger> </log4net> </configuration>

推荐答案

这是一个疯狂的猜测,但是您是否已将log4net.config文件的构建操作"标记为内容",并将其属性设置为复制到输出"目录"到始终复制".

This is a wild guess, but have you marked "Build Action" of your log4net.config file as 'Content', and set it's property "Copy to Output directory" to "Copy always".

通过这种方式,您不必复制文件,该文件将被视为构建输出的内容",并将包含在您的发布中.

This way you don't have to copy file, and this file is considered as 'content' of the build output and will be included in your publish.

更多推荐

log4net控制台应用程序未登录发布

本文发布于:2023-11-15 22:11:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598404.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制台   应用程序   log4net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!