[ 
https://issues.apache.org/jira/browse/LOG4NET-274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12983336#action_12983336
 ] 

Petr Felzmann commented on LOG4NET-274:
---------------------------------------

I found the solution: the output type of your project must be Console 
Application instead of Windows Application. When you change this in your 
project settings then your application starts logging also after compilation in 
Release mode. And it is not related to whether the exe runs as windows service 
or not. You are able to reproduce this behavior with console app as well.

I tried to put assembly attribute to the log4net code

[assembly: 
System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]

and recompile it with .NET FW 4.0, but this didn't help. So the only solution 
is to use Console Application as output type of your project. But still I don't 
have idea why the behavior is like this and what has changed in .NET FW 4.0 to 
cause it.

So now the priority of this issue definitely isn't Blocker ;-)

> log4net doesn't log when running a .Net 4.0 Windows application built in 
> Release mode
> -------------------------------------------------------------------------------------
>
>                 Key: LOG4NET-274
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-274
>             Project: Log4net
>          Issue Type: Bug
>    Affects Versions: 1.2.10
>         Environment: Visual Studio 2010, C#, Windows 7
>            Reporter: Deepu Thomas Palathara
>            Priority: Blocker
>             Fix For: 1.2.10
>
>
> I've a .Net 4.0 windows service application that uses log4net.
> Here's my log4net config.
> <log4net>
>   <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
>     <layout type="log4net.Layout.PatternLayout">
>       <conversionPattern value="%date [%thread] %-5level %logger 
> [%property{Context}] - %message%newline" />
>     </layout>
>   </appender>
>   <appender name="ColorConsoleAppender" 
> type="log4net.Appender.ColoredConsoleAppender">
>     <mapping>
>       <level value="ERROR" />
>       <foreColor value="Red, HighIntensity" />
>     </mapping>
>     <mapping>
>       <level value="FATAL" />
>       <foreColor value="Red, HighIntensity" />
>     </mapping>
>     <mapping>
>       <level value="WARN" />
>       <foreColor value="Blue, HighIntensity" />
>     </mapping>
>     <mapping>
>       <level value="INFO" />
>       <forecolor value="White, HighIntensity" />
>     </mapping>
>     <mapping>
>       <level value="DEBUG" />
>       <forecolor value="Green, HighIntensity" />
>     </mapping>
>     <layout type="log4net.Layout.PatternLayout">
>       <conversionPattern value="%date [%thread] %-5level %logger 
> [%property{Context}] - %message%newline" />
>     </layout>
>   </appender>
>   <appender name="RollingFileAppender" 
> type="log4net.Appender.RollingFileAppender">
>     <appendToFile value="true" />
>     <datePattern value="yyyyMMdd" />
>     <file value="Logs/Server.log" />
>     <layout type="log4net.Layout.PatternLayout">
>       <conversionPattern value="%date [%thread] %-5level %logger 
> [%property{Context}] - %message%newline" />
>     </layout>
>     <maximumFileSize value="10MB" />
>     <rollingStyle value="Composite" />
>     <staticLogFileName value="true" />
>   </appender>
>   <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
>     <layout type="log4net.Layout.PatternLayout">
>       <conversionPattern value="%date [%thread] %-5level %logger 
> [%property{Context}] - %message%newline" />
>     </layout>
>   </appender>
>   <root>
>     <level value="ALL" />
>     <appender-ref ref="ColorConsoleAppender" />
>     <appender-ref ref="RollingFileAppender" />
>   </root>
> </log4net>
> Logging works as expected when the service starts up while using the exe that 
> was built in debug mode (log files are created at the right file path), but 
> doesn't work when it is using the exe built in release mode.
> I've even tried using a recompiled log4net dll for .Net 4.0 following the 
> steps mentioned at this blog.. 
> http://tseonet.blogspot.com/2010/07/making-log4net-run-on-net-40.html. 
> That didn't work either. I was able to compile and run the service. But the 
> result was the same; no logs when using the exe build in release mode.
> Not sure what's going on. Cannot deploy the application built in debug mode 
> into production.
> Any help is greatly appreciated.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to