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" <[EMAIL PROTECTED]>
To: [email protected]
Sent: Friday, March 7, 2008 11:44:26 AM
Subject: Reusable layouts ...

  
<!--
 _filtered {font-family:Fixedsys;panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"Times 
New Roman";}
a:link, span.MsoHyperlink
        {color:blue;text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;text-decoration:underline;}
span.EmailStyle17
        {font-family:Arial;color:windowtext;}
 _filtered {margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {}
-->
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>



   
 



Reply via email to