logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: How to make a part of log message uppercase
Date Mon, 22 Jun 2009 21:22:26 GMT
This should work:

// untested
public class HostNameToUpperLayout : LayoutSkeleton
{
    public override void ActivateOptions()
    {
        // empty
    }

    public override void Format(TextWriter writer, LoggingEvent loggingEvent)
    {
        string hostName = (string)loggingEvent.LookupProperty("log4net:HostName");
        writer.Write(hostName.ToUpper());
    }
}

<parameter>
      <parameterName value="@message"/>
      <dbType value="String"/>
      <size value="4000"/>
      <layout type="Company.Application.HostNameToUpperLayout, Company.Application" />
</parameter>

There are more clever ways of doing it but that should work.




________________________________
From: Cankut Eskin <cankuteskin@gmail.com>
To: Log4NET User <log4net-user@logging.apache.org>
Sent: Monday, June 22, 2009 9:09:37 AM
Subject: How to make a part of log message uppercase

Hello,

I'm using AdoNetAppender to log messages. I've added %property{log4net:HostName} conversion
pattern to the message parameter.

<parameter>
      <parameterName value="@message"/>
      <dbType value="String"/>
      <size value="4000"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="[%property{log4net:HostName}] - %message"/>
      </layout>
</parameter>

Output is like

[hostname] - foo bar.

But i want the output like

[HOSTNAME] - foo bar.

How can i make the hostname uppercase using conversion patterns?

Regards,

Cankut

Mime
View raw message