logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominik Psenner (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (LOG4NET-453) log4net.Appender.ColoredConsoleAppender Fail Under Mono
Date Wed, 25 Feb 2015 08:13:04 GMT

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

Dominik Psenner edited comment on LOG4NET-453 at 2/25/15 8:12 AM:
------------------------------------------------------------------

The quick solution is to use the ConsoleAppender instead.

However, if you're willing to invest some time to get colored output on the console you could
help us fixing this by building log4net from source and modifying this line:

System.Text.Encoding consoleEncoding = System.Text.Encoding.GetEncoding(GetConsoleOutputCP());

to be:

System.Text.Encoding consoleEncoding = Console.OutputEncoding;

Unfortunately I have no possibility to test this with Mono 3.x on a Linux box, but if this
works for you we might have a patch that works. However, I'm not so confident this could work
because of the .NET Core Notes mentioned here:

https://msdn.microsoft.com/en-us/library/system.console%28v=vs.110%29.aspx

It might be that Console.OutputEncoding returns UTF8 most of the times as a general rule of
behaviour and thus neglects the existence of codepages and outputting colored characters might
depend on the exact knowledge of the codepage. But again, this is all very speculative.


was (Author: nachbarslumpi):
The quick solution is to use the ConsoleAppender instead. You could try to build log4net from
source and modify this line:

System.Text.Encoding consoleEncoding = System.Text.Encoding.GetEncoding(GetConsoleOutputCP());

to be:

System.Text.Encoding consoleEncoding = Console.OutputEncoding;

Unfortunately I have no possibility to test this with Mono 3.x on a Linux box, but if this
works for you we might have a patch that works. However, I'm not so confident this could work
because of the .NET Core Notes mentioned here:

https://msdn.microsoft.com/en-us/library/system.console%28v=vs.110%29.aspx

It might be that Console.OutputEncoding returns UTF8 most of the times as a general rule of
behaviour and thus neglects the existence of codepages and outputting colored characters might
depend on the exact knowledge of the codepage. But again, this is all very speculative.

> log4net.Appender.ColoredConsoleAppender Fail Under Mono
> -------------------------------------------------------
>
>                 Key: LOG4NET-453
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-453
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.11
>         Environment: Mono 3.x under Linux Centos/Debian/Ubuntu
>            Reporter: Syeh Abidin
>
> I am trying to use log4net.Appender.ColoredConsoleAppender 
> under mono, but seem failed with message :
> log4net:ERROR Could not create Appender [A1] of type [log4net.Appender.ColoredConsoleAppender].
Reported error follows.
> System.EntryPointNotFoundException: GetConsoleOutputCP
>   at (wrapper managed-to-native) log4net.Appender.ColoredConsoleAppender:GetConsoleOutputCP
()
>   at log4net.Appender.ColoredConsoleAppender.ActivateOptions () [0x00000] in <filename
unknown>:0
>   at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender (System.Xml.XmlElement
appenderElement) [0x00000] in <filename unknown>:0
> it seem bug issue,
> the log4net.xml is simple:
>  <appender name="A1" type="log4net.Appender.ColoredConsoleAppender">
>         <layout type="log4net.Layout.PatternLayout">
>             <conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline"
/>
>         </layout>
>         <mapping>
>             <level value="INFO" />
>             <foreColor value="White, HighIntensity" />
>             <backColor value="Green" />
>         </mapping>
>         <mapping>
>             <level value="DEBUG" />
>             <foreColor value="White, HighIntensity" />
>             <backColor value="Blue" />
>         </mapping>
>         <mapping>
>             <level value="WARN" />
>             <foreColor value="Yellow, HighIntensity" />
>             <backColor value="Purple" />
>         </mapping>
>         <mapping>
>             <level value="ERROR" />
>             <foreColor value="Yellow, HighIntensity" />
>             <backColor value="Red" />
>         </mapping>
>     </appender>



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message