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: Reusable layouts ...
Date Sun, 09 Mar 2008 17:42:24 GMT
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 ...

 _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
a:visited, span.MsoHyperlinkFollowed
 _filtered {margin:1.0in 1.25in 1.0in 1.25in;}
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?
 Ken Parrish
 Gomez, Inc.
Standard rolling file appender -->
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
value="RollingFile.log" />
      <appendToFile value="true"
      <rollingStyle value="Size"
      <maxSizeRollBackups value="10"
      <maximumFileSize value="10MB"
name="ConversionPattern" value="%date{yyyy-MM-dd HH:mm:ss.fff} [%t] %-5level
%logger - %message%newline%exception" />

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


View raw message