Return-Path: Delivered-To: apmail-logging-log4net-user-archive@www.apache.org Received: (qmail 4423 invoked from network); 9 Mar 2008 17:42:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Mar 2008 17:42:58 -0000 Received: (qmail 66687 invoked by uid 500); 9 Mar 2008 17:42:53 -0000 Delivered-To: apmail-logging-log4net-user-archive@logging.apache.org Received: (qmail 66669 invoked by uid 500); 9 Mar 2008 17:42:53 -0000 Mailing-List: contact log4net-user-help@logging.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Log4NET User" List-Id: Delivered-To: mailing list log4net-user@logging.apache.org Received: (qmail 66658 invoked by uid 99); 9 Mar 2008 17:42:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Mar 2008 10:42:53 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [68.142.200.121] (HELO web30508.mail.mud.yahoo.com) (68.142.200.121) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 09 Mar 2008 17:42:15 +0000 Received: (qmail 15767 invoked by uid 60001); 9 Mar 2008 17:42:24 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Message-ID; b=JmpLGTce/7tFYgQpVjfI9iQumzxuqIZmCKWPzMPzeF1RjSCHUe5L/ucR1om1q1gvw97ynHLPkgzCvdy51ksA1DjN7j59sR0kXP+OveqTmEcMRLic2VOv6X2gDk4m/l7+qXlMycqNpiyZqpBgVakX8ly3GdtUuN9yB2KU6udO+8E=; X-YMail-OSG: vxgqQi0VM1myMEgfeEsbvC5K3A7.TpN5OTxjqWJt2_xAMTi5x8ucNvHs0UmM2X7Zt9EyLHbuhA-- Received: from [75.179.188.181] by web30508.mail.mud.yahoo.com via HTTP; Sun, 09 Mar 2008 10:42:24 PDT X-Mailer: YahooMailRC/902.35 YahooMailWebService/0.7.162 Date: Sun, 9 Mar 2008 10:42:24 -0700 (PDT) From: Ron Grabowski Subject: Re: Reusable layouts ... To: Log4NET User MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-178341284-1205084544=:15079" Message-ID: <793600.15079.qm@web30508.mail.mud.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org --0-178341284-1205084544=:15079 Content-Type: text/plain; charset=us-ascii You could make a custom PatternLayout class: You could also add a property to the repository then write a layout that looks for that property by default: ----- Original Message ---- From: "Parrish, Ken" To: log4net-user@logging.apache.org Sent: Friday, March 7, 2008 11:44:26 AM Subject: Reusable layouts ... Is there a way in a log4net configuration file to specify a layout pattern and then reference that pattern from multiple appenders. In the following config file snippet, the same layout specification is used by two different appenders. Is there a way to specify the pattern just once and reference that patter by each of the two appenders? Thanks, Ken Parrish Gomez, Inc. --0-178341284-1205084544=:15079 Content-Type: text/html; charset=us-ascii
You could make a custom PatternLayout class:

 <layout type="Company.Log4NetIntegration.DateThreadLevelLoggerLayout, Company.Log4NetIntegration">

You could also add a property to the repository then write a layout that looks for that property by default:

 <!-- looks for the property "defaultConversionPattern" in the repositories properties -->
 <layout type="Company.Log4netIntegration.RepLayout, Company.Log4netIntegration" />

----- Original Message ----
From: "Parrish, Ken" <KParrish@gomez.com>
To: log4net-user@logging.apache.org
Sent: Friday, March 7, 2008 11:44:26 AM
Subject: Reusable layouts ...

Is there a way in a log4net configuration file to specify a layout pattern and then reference that pattern from multiple appenders.  In the following config file snippet, the same layout specification is used by two different appenders.  Is there a way to specify the pattern just once and reference that patter by each of the two appenders?

 

Thanks,

 

Ken Parrish

Gomez, Inc.

 

<!-- Standard rolling file appender -->
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
     
<file value="RollingFile.log" />
     
<appendToFile value="true" />
     
<rollingStyle value="Size" />
     
<maxSizeRollBackups value="10" />
     
<maximumFileSize value="10MB" />
     
<layout type="log4net.Layout.PatternLayout">
           
<param name="ConversionPattern" value="%date{yyyy-MM-dd HH:mm:ss.fff} [%t] %-5level %logger - %message%newline%exception" />
     
</layout>
</appender>

<!-- Windows Application Event Log appender -->
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
     
<applicationName value="MyApplication" />
     
<layout type="log4net.Layout.PatternLayout">
           
<param name="ConversionPattern" value="%date{yyyy-MM-dd HH:mm:ss.fff} [%t] %-5level %logger - %message%newline%exception" />
     
</layout>
</appender>


 


--0-178341284-1205084544=:15079--