logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From harry.dougl...@pnc.com
Subject Re: Non Buffering SMTP Appender
Date Fri, 19 May 2006 13:11:09 GMT
Tobi,

If you only want to see log messages for ERRORS, for example, you have to
put the threshold element on its own.  In this code section, I will only
get e-mails when an ERROR log is encountered.  If you put it inside the
threshold element, you'll always get a log message.  In my example, I only
get log messages for errors.  But,  if I hit a DEBUG log, I get all the log
messages.

 <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
     <to value="youremail@something.com" />
      <from value="youremail@something.com" />
      <subject value="Application Error" />
      <smtpHost value="yourhost" />
      <bufferSize value="512" />
      <lossy value="true" />
      <threshold value="ERROR"/>
      <evaluator type="log4net.Core.LevelEvaluator">
        <threshold value="DEBUG"/>
      </evaluator>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%newline%date [%thread] %-5level %logger
[%property{NDC}] - %message%newline%newline%newline" />
      </layout>
    </appender>

Harry Douglass
Consumer Lending Application Development
X2-1035




                                                                           
             Tobias Schröer                                                
             <schroeer@busitec                                             
             .de>                                                       To 
                                       <log4net-user@logging.apache.org>   
             05/19/2006 03:05                                           cc 
             AM                                                            
                                                                   Subject 
                                       Non Buffering SMTP Appender         
             Please respond to                                             
              "Log4NET User"                                               
             <log4net-user@log                                             
             ging.apache.org>                                              
                                                                           
                                                                           




Hi,

I'm using log4net 1.2.10.0 and I'm encoutering the problem that the SMTP
Appender does not buffer. I receive an e-mail for every log message. This
is the appenders configuration:

<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
  <to value="mail@domain.de" />
  <from value="otherMail@domain.de" />
  <subject value="Error message" />
  <smtpHost value="hostname" />
  <userName value="user" />
  <password value="pwd" />
  <bufferSize value="512" />
  <lossy value="false" />
  <evaluator type="log4net.Core.LevelEvaluator">
    <threshold value="ERROR"/>
  </evaluator>
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%newline%date %-5level %logger -
%message%newline%newline" />
  </layout>
</appender>

The odd thing is, that on my development machine (WinXP Pro) the appender
behaves as expected, but not on the production machine (Win 2003). Both
machines run .NET 1.1.
I even tried to wrap the SMTPAppender in BufferingForwardingAppender, with
no sucess :(

The internal logging output for a program run is this:

log4net: log4net assembly [log4net, Version=1.2.10.0, Culture=neutral,
PublicKeyToken=1b44e1d426115821]. Loaded from
[d:\eloprof\prog\archivecomparer\log4net.dll]. (.NET Runtime [1.1.4322.573]
on Microsoft Windows NT 5.2.3790.0)
log4net: DefaultRepositorySelector: defaultRepositoryType
[log4net.Repository.Hierarchy.Hierarchy]
log4net: DefaultRepositorySelector: Creating repository for assembly
[ConsoleArchiveComparer, Version=1.0.2327.27481, Culture=neutral,
PublicKeyToken=null]
log4net: DefaultRepositorySelector: Assembly [ConsoleArchiveComparer,
Version=1.0.2327.27481, Culture=neutral, PublicKeyToken=null] Loaded From
[D:\eloprof\Prog\ArchiveComparer\ConsoleArchiveComparer.exe]
log4net: DefaultRepositorySelector: Assembly [ConsoleArchiveComparer,
Version=1.0.2327.27481, Culture=neutral, PublicKeyToken=null] does not have
a RepositoryAttribute specified.
log4net: DefaultRepositorySelector: Assembly [ConsoleArchiveComparer,
Version=1.0.2327.27481, Culture=neutral, PublicKeyToken=null] using
repository [log4net-default-repository] and repository type
[log4net.Repository.Hierarchy.Hierarchy]
log4net: DefaultRepositorySelector: Creating repository
[log4net-default-repository] using type
[log4net.Repository.Hierarchy.Hierarchy]
log4net: XmlConfigurator: configuring repository
[log4net-default-repository] using .config file section
log4net: XmlConfigurator: Application config file is
[D:\eloprof\Prog\ArchiveComparer\ConsoleArchiveComparer.exe.config]
log4net: XmlConfigurator: Configuring Repository
[log4net-default-repository]
log4net: XmlHierarchyConfigurator: Configuration update mode [Merge].
log4net: XmlHierarchyConfigurator: Retrieving an instance of
log4net.Repository.Logger for logger [De].
log4net: XmlHierarchyConfigurator: Setting [De] additivity to [True].
log4net: XmlHierarchyConfigurator: Logger [De] Level string is [Info].
log4net: XmlHierarchyConfigurator: Logger [De] level set to
[name="INFO",value=40000].
log4net: XmlHierarchyConfigurator: Loading Appender [FileAppender] type:
[log4net.Appender.FileAppender]
log4net: XmlHierarchyConfigurator: Setting Property [File] to String value
[TechLog.log]
log4net: XmlHierarchyConfigurator: Setting Property [AppendToFile] to
Boolean value [True]
log4net: PatternParser: Converter [message] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [newline] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: XmlHierarchyConfigurator: Setting Property [ConversionPattern] to
String value [%date %-5level %logger - %message%newline]
log4net: PatternParser: Converter [date] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [literal] Option [ ] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [level] Option [] Format
[min=5,max=2147483647,leftAlign=True]
log4net: PatternParser: Converter [literal] Option [ ] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [logger] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [literal] Option [ - ] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [message] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [newline] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: XmlHierarchyConfigurator: Setting Property [Layout] to object
[log4net.Layout.PatternLayout]
log4net: FileAppender: Opening file for writing
[D:\eloprof\Prog\ArchiveComparer\TechLog.log] append [True]
log4net: XmlHierarchyConfigurator: Created Appender [FileAppender]
log4net: XmlHierarchyConfigurator: Adding appender named [FileAppender] to
logger [De].
log4net: XmlHierarchyConfigurator: Retrieving an instance of
log4net.Repository.Logger for logger [ArchiveComparer].
log4net: XmlHierarchyConfigurator: Setting [ArchiveComparer] additivity to
[True].
log4net: XmlHierarchyConfigurator: Logger [ArchiveComparer] Level string is
[WARN].
log4net: XmlHierarchyConfigurator: Logger [ArchiveComparer] level set to
[name="WARN",value=60000].
log4net: XmlHierarchyConfigurator: Loading Appender [FileAppender2] type:
[log4net.Appender.FileAppender]
log4net: XmlHierarchyConfigurator: Setting Property [File] to String value
[ComparerLog.log]
log4net: XmlHierarchyConfigurator: Setting Property [AppendToFile] to
Boolean value [True]
log4net: PatternParser: Converter [message] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [newline] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: XmlHierarchyConfigurator: Setting Property [ConversionPattern] to
String value [%date %-5level %logger - %message%newline]
log4net: PatternParser: Converter [date] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [literal] Option [ ] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [level] Option [] Format
[min=5,max=2147483647,leftAlign=True]
log4net: PatternParser: Converter [literal] Option [ ] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [logger] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [literal] Option [ - ] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [message] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [newline] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: XmlHierarchyConfigurator: Setting Property [Layout] to object
[log4net.Layout.PatternLayout]
log4net: FileAppender: Opening file for writing
[D:\eloprof\Prog\ArchiveComparer\ComparerLog.log] append [True]
log4net: XmlHierarchyConfigurator: Created Appender [FileAppender2]
log4net: XmlHierarchyConfigurator: Adding appender named [FileAppender2] to
logger [ArchiveComparer].
log4net: XmlHierarchyConfigurator: Loading Appender [SmtpAppender] type:
[log4net.Appender.SmtpAppender]
log4net: XmlHierarchyConfigurator: Setting Property [To] to String value
[mail@domain.de]
log4net: XmlHierarchyConfigurator: Setting Property [From] to String value
[otherMail@domain.de]
log4net: XmlHierarchyConfigurator: Setting Property [Subject] to String
value [Error message]
log4net: XmlHierarchyConfigurator: Setting Property [SmtpHost] to String
value [hostname]
log4net: XmlHierarchyConfigurator: Setting Property [Username] to String
value [user]
log4net: XmlHierarchyConfigurator: Setting Property [Password] to String
value [pwd]
log4net: XmlHierarchyConfigurator: Setting Property [BufferSize] to Int32
value [512]
log4net: XmlHierarchyConfigurator: Setting Property [Lossy] to Boolean
value [False]
log4net: XmlHierarchyConfigurator: Setting Property [Threshold] to Level
value [ERROR]
log4net: XmlHierarchyConfigurator: Setting Property [Evaluator] to object
[log4net.Core.LevelEvaluator]
log4net: PatternParser: Converter [message] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [newline] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: XmlHierarchyConfigurator: Setting Property [ConversionPattern] to
String value [%newline%date %-5level %logger - %message%newline%newline]
log4net: PatternParser: Converter [newline] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [date] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [literal] Option [ ] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [level] Option [] Format
[min=5,max=2147483647,leftAlign=True]
log4net: PatternParser: Converter [literal] Option [ ] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [logger] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [literal] Option [ - ] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [message] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [newline] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: PatternParser: Converter [newline] Option [] Format
[min=-1,max=2147483647,leftAlign=False]
log4net: XmlHierarchyConfigurator: Setting Property [Layout] to object
[log4net.Layout.PatternLayout]
log4net: XmlHierarchyConfigurator: Created Appender [SmtpAppender]
log4net: XmlHierarchyConfigurator: Adding appender named [SmtpAppender] to
logger [ArchiveComparer].
log4net: XmlHierarchyConfigurator: Hierarchy Threshold []
log4net: DefaultRepositorySelector: Creating repository for assembly
[ArchiveComparer, Version=1.0.2327.28169, Culture=neutral,
PublicKeyToken=null]
log4net: DefaultRepositorySelector: Assembly [ArchiveComparer,
Version=1.0.2327.28169, Culture=neutral, PublicKeyToken=null] Loaded From
[d:\eloprof\prog\archivecomparer\archivecomparer.dll]
log4net: DefaultRepositorySelector: Assembly [ArchiveComparer,
Version=1.0.2327.28169, Culture=neutral, PublicKeyToken=null] does not have
a RepositoryAttribute specified.
log4net: DefaultRepositorySelector: Assembly [ArchiveComparer,
Version=1.0.2327.28169, Culture=neutral, PublicKeyToken=null] using
repository [log4net-default-repository] and repository type
[log4net.Repository.Hierarchy.Hierarchy]
log4net: DefaultRepositorySelector: repository [log4net-default-repository]
already exists, using repository type
[log4net.Repository.Hierarchy.Hierarchy]
log4net: Hierarchy: Shutdown called on Hierarchy
[log4net-default-repository]


Any ideas?

Tobi



The contents of this email are the property of PNC. If it was not addressed to you, you have
no legal right to read it. If you think you received it in error, please notify the sender.
Do not forward or copy without permission of the sender. This message may contain an advertisement
of a product or service and thus may constitute a commercial electronic mail message under
US Law. PNC’s postal address is 249 Fifth Avenue, Pittsburgh, PA 15222. If you do not wish
to receive any additional advertising or promotional messages from PNC at this e-mail address,
click here to Unsubscribe. https://pnc.p.delivery.net/m/u/pnc/uni/p.asp By unsubscribing to
this message, you will be unsubscribed from all advertising or promotional messages from PNC.
Removing your e-mail address from this mailing list will not affect your subscription to alerts,
e-newsletters or account servicing e-mails..

Mime
View raw message