Re: FileAppender problem

2011-02-15 Thread Jacob Kjome
I suggest using a ServletContextLister and calling LogManager.shutdown() when 
your webapp is stopped.


http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/LogManager.html#shutdown%28%29

http://stackoverflow.com/questions/839255/how-do-i-properly-log4j-closing-all-appenders-and-therefore-files


Jake


On Tue, 15 Feb 2011 10:06:57 +0530
 Umesh Awasthi umeshawas...@gmail.com wrote:

Josef,

Thanks for the help.i able to solve the problem and here is the casue of the
problem'.
since i was creating fileappender instance
appender = new FileAppender(layout, sb.toString(), false);
inside the constructor of my class and i was of impression that log4j is
responsible for closing the appender which in my case was not happening at
all.
so after looking in to the FileAppender source code i got the hint since in
the code they tried to close the appender but code was indicating that there
may be some cases where appender might still be open and my problem was in
this section,so after doing my work i simply closed the appender and it
solved the whole issue.

still i am not sure how tomcat was keeping refrence of all the appender
created by the code since i was cleaning up my code and was making all
refrences null.

any one have idea,please do share



On Mon, Feb 14, 2011 at 11:23 PM, Stadelmann Josef 
josef.stadelm...@axa-winterthur.ch wrote:


In case you have conflicts, it is a good Idea to consolidate all different
log4j.properties into one big log4j.properties and have that used when
TOMCAT starts. This just fior a test. If then all runs, then your problems
may be that of a access conflict; i.e. trying to open a file or a channel
which is already open.

It helped for me in many case.
Josef



-Ursprüngliche Nachricht-
Von: Umesh Awasthi [mailto:umeshawas...@gmail.com]
Gesendet: Montag, 14. Februar 2011 15:35
An: log4j-user
Betreff: Re: FileAppender problem

Hi All,

Can any one help me in this,it seems the my tomcat server keeping a
refrence
of all fileappender

On Sat, Feb 12, 2011 at 11:22 AM, Umesh Awasthi umeshawas...@gmail.com
wrote:

 Hi All,

 I am working on a webapplication and i have a requirment to generate log
 files at run time for my impex process.here is the use case
 i am validating an XML file and validation error is being handled by
custom
 Error handler.This error hanlde will be passed to the underlying
validator
 (Jaxb 2.x validator),so i have to create the log file when the instance
of
 this error hanlder is being created.

 here is the code to create log file at run time
 FileAppender appender;
 try {
 appender = new FileAppender(layout, sb.toString(),
false);
 log.addAppender(appender);
 log.setAdditivity(false);
 log.setLevel(Level.WARN);
 } catch (IOException e) {
 e.printStackTrace();
 }

 everything is working fine and file is being created correctly as well
 being written by the logger to the respective place.
 but if i restart my server real problem starts and logger starting
 appending the log content not only to its pareent class as well other
 classes.here is the details
 lets suppose i have 3 log (A,B,C) files already at the location with 3
 lines in each log file and C was the latest file created in the process.
  so when i restart my server it some how appending data in to previos all
 log files in this fashin
 C has still 3 lines
 B has now 6 lines
 A has now 9 lines

 it seems that the appender i hace created is still open or have refrence
 not sure what exactly going on.
 any help in this regard will be helpfull.


 --
 With Regards
 Umesh Awasthi
 http://www.travellingrants.com/






--
With Regards
Umesh Awasthi
http://www.travellingrants.com/

-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org





--
With Regards
Umesh Awasthi
http://www.travellingrants.com/



-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: FileAppender problem

2011-02-15 Thread umeshawasthi
I was thinking the same line but problem solved only by closing the appender 
when work done
Sent from BlackBerry® on Airtel

-Original Message-
From: Jacob Kjome h...@visi.com
Date: Tue, 15 Feb 2011 09:45:15 
To: Log4J Users Listlog4j-user@logging.apache.org
Reply-To: Log4J Users List log4j-user@logging.apache.org
Subject: Re: FileAppender problem

I suggest using a ServletContextLister and calling LogManager.shutdown() when 
your webapp is stopped.

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/LogManager.html#shutdown%28%29

http://stackoverflow.com/questions/839255/how-do-i-properly-log4j-closing-all-appenders-and-therefore-files


Jake


On Tue, 15 Feb 2011 10:06:57 +0530
 Umesh Awasthi umeshawas...@gmail.com wrote:
 Josef,
 
 Thanks for the help.i able to solve the problem and here is the casue of the
 problem'.
 since i was creating fileappender instance
 appender = new FileAppender(layout, sb.toString(), false);
 inside the constructor of my class and i was of impression that log4j is
 responsible for closing the appender which in my case was not happening at
 all.
 so after looking in to the FileAppender source code i got the hint since in
 the code they tried to close the appender but code was indicating that there
 may be some cases where appender might still be open and my problem was in
 this section,so after doing my work i simply closed the appender and it
 solved the whole issue.
 
 still i am not sure how tomcat was keeping refrence of all the appender
 created by the code since i was cleaning up my code and was making all
 refrences null.
 
 any one have idea,please do share
 
 
 
 On Mon, Feb 14, 2011 at 11:23 PM, Stadelmann Josef 
 josef.stadelm...@axa-winterthur.ch wrote:
 
 In case you have conflicts, it is a good Idea to consolidate all different
 log4j.properties into one big log4j.properties and have that used when
 TOMCAT starts. This just fior a test. If then all runs, then your problems
 may be that of a access conflict; i.e. trying to open a file or a channel
 which is already open.

 It helped for me in many case.
 Josef



 -Ursprüngliche Nachricht-
 Von: Umesh Awasthi [mailto:umeshawas...@gmail.com]
 Gesendet: Montag, 14. Februar 2011 15:35
 An: log4j-user
 Betreff: Re: FileAppender problem

 Hi All,

 Can any one help me in this,it seems the my tomcat server keeping a
 refrence
 of all fileappender

 On Sat, Feb 12, 2011 at 11:22 AM, Umesh Awasthi umeshawas...@gmail.com
 wrote:

  Hi All,
 
  I am working on a webapplication and i have a requirment to generate log
  files at run time for my impex process.here is the use case
  i am validating an XML file and validation error is being handled by
 custom
  Error handler.This error hanlde will be passed to the underlying
 validator
  (Jaxb 2.x validator),so i have to create the log file when the instance
 of
  this error hanlder is being created.
 
  here is the code to create log file at run time
  FileAppender appender;
  try {
  appender = new FileAppender(layout, sb.toString(),
 false);
  log.addAppender(appender);
  log.setAdditivity(false);
  log.setLevel(Level.WARN);
  } catch (IOException e) {
  e.printStackTrace();
  }
 
  everything is working fine and file is being created correctly as well
  being written by the logger to the respective place.
  but if i restart my server real problem starts and logger starting
  appending the log content not only to its pareent class as well other
  classes.here is the details
  lets suppose i have 3 log (A,B,C) files already at the location with 3
  lines in each log file and C was the latest file created in the process.
   so when i restart my server it some how appending data in to previos all
  log files in this fashin
  C has still 3 lines
  B has now 6 lines
  A has now 9 lines
 
  it seems that the appender i hace created is still open or have refrence
  not sure what exactly going on.
  any help in this regard will be helpfull.
 
 
  --
  With Regards
  Umesh Awasthi
  http://www.travellingrants.com/
 
 
 



 --
 With Regards
 Umesh Awasthi
 http://www.travellingrants.com/

 -
 To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
 For additional commands, e-mail: log4j-user-h...@logging.apache.org


 
 
 -- 
 With Regards
 Umesh Awasthi
 http://www.travellingrants.com/


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Custom EvaluatorClass with SMTPAppender when returning true sends PREVIOUS log message

2011-02-15 Thread Papierman, Paul
1)  I've created a custom Evaluator class that I wish to use for the 
SMTPAppender to not send the same emails for errors over a period of time.


2)  I've added it to my log4j.xml configuration:
   !-- Buffer events and log them asynchronously --
   appender name=ASYNC class=org.apache.log4j.AsyncAppender
 errorHandler class=org.jboss.logging.util.OnlyOnceErrorHandler/
 appender-ref ref=FILE/
 appender-ref ref=CONSOLE/
 appender-ref ref=SMTP/
   /appender


   !-- EMail events to an administrator --
   appender name=SMTP class=org.apache.log4j.net.SMTPAppender
 errorHandler class=org.jboss.logging.util.OnlyOnceErrorHandler/
 !-- this is our custom TriggeringEventEvaluator --
 param name=EvaluatorClass 
value=com.somewhere.log4j.LimitingTriggeringEventEvaluator/
 param name=Threshold value=ERROR/
 param name=To 
value=myem...@somewhere.commailto:myem...@somewhere.com/
 param name=From 
value=lo...@somewhere.commailto:lo...@somewhere.com/
 param name=Subject value=LOCALHOST NODE1/
 param name=SMTPHost value=smtp.somewhere.com/
 param name=BufferSize value=100/
 layout class=org.apache.log4j.PatternLayout
   param name=ConversionPattern value=[%d{ABSOLUTE},%c{1}] %m%n/
 /layout
   /appender


3)  I know it's working because I log (via STDOUT) and I can see that 
isTriggeringEvent is returning false (appropriately) when the same message 
appears within a time interval. (I tried using LogLog but it doesn't seem to 
work with JBoss - that's another story)



4)  Most times when I log that I'm returning true (from isTriggeringEvent) 
because the message is a unique one what I receive via email is the Text from a 
PREVIOUS message.



-It sounds like the SMTPAppender Buffer is not working the way its 
supposed to - or there are multiple 'buffers' being created per JVM?

-Or is the issue the ASYNC aspect of how the messages are being logged?



In any case its definitely not working as expected. When I return true in 
isTriggeringEvent, I want to send an email for the message referenced in the 
LoggingEvent that I just evaluated.



Here's what's happening:

1 = boot application, my internal table is empty so all messages are 'new'

2 - log.error(AAA)  - isTriggeringEvent retrurns true, this results in an 
email sent with AAA as the contents which is correct

3 - log.error(AAA)  - isTriggeringEvent retrurns false, this results in no 
email sent which is correct since AAA has occurred already

4 - log.error(BBB)  - isTriggeringEvent retrurns true, which is correct since 
BBB has not been sent yet. But the email that I receive has the message (AAA) 
which is incorrect. It should have the contents of the evaluated message, BBB



Any help?





Notice: This e-mail message, together with any attachments, contains 
information of eRT that may be confidential, proprietary copyrighted and/or 
legally privileged, and is intended solely for the use of the individual or 
entity named on this message. If you are not the intended recipient, and have 
received this message in error, please immediately return this by e-mail and 
then delete it.


Re: can't get UDPAppender to work

2011-02-15 Thread rvarum

thanks for you answer Rodney.

i'm little lost with Java. 

i took PortBased.java , NetworkBased.java and UDPAppender.java from the svn 
and made 3 jars from them using:  jar cf file.jar file.java 
i put the 3 jars in the lib folder of the jboss where log4j.lib is, but it
didn't help.
i also moved the appender section above the root element.

am i in the right direction?
should i create a jar with special names?  1 jar?  3 jars?

i know its a little bit out of the scope here, but i really dont know where
to go from here.

Thanks,
Roy.


Rodney Beede-2 wrote:
 
 You will need additional jars in order to that appender with a Java
 application.
 http://logging.apache.org/log4j/companions/receivers/apidocs/org/apache/log4j/net/UDPAppender.html
 Note that there is also log4jnet which has this appender for .NET
 applications so don't confuse them.
 
 http://logging.apache.org/log4j/companions/receivers/apidocs/org/apache/log4j/net/UDPAppender.htmlThe
 log4j companions receiver package hasn't been released yet.  You can get
 the
 source from
 http://svn.apache.org/repos/asf/logging/log4j/companions/receivers/trunk/
 and
 build it yourself.  I can't find any jars of it in any Maven repos.
 
 Additionally your UDP appender should probably be above the root element.
 
 On Mon, Feb 14, 2011 at 7:59 AM, rvarum r...@supportspace.com wrote:
 

 i think i did that.

 i attached a copy of the entire xml.
 http://old.nabble.com/file/p30922474/jboss-log4j.xml jboss-log4j.xml


 Rodney Beede-5 wrote:
 
  You probably forgot to add the appender to your root.  A complete copy
 of
  your log4j.xml would help.
 
  On Mon, Feb 14, 2011 at 1:49 AM, rvarum r...@supportspace.com wrote:
 
 
  Hi all,
 
  i'm an automation developer with QTP (not java developer)
 
  i'm trying to configure the log4j of our application to broadcast the
 log
  messages through UDP protocol using the UDPAppender, so i can't catch
 and
  process log messages.
 
  the application uses log4j version 1.2.16.
  this is the appender configuration i'm using in the log4j xml conf:
 
   appender name=QtpUdpAppender
  class=org.apache.log4j.net.UDPAppender
 
 
 
 layout class=org.apache.log4j.xml.XMLLayout
 
 /layout
   /appender
 
 
  i used several tools and log4j consoles in order to listen to the UDP
  port
  on my machine.
  i'm getting nothing from the jboss on that port.
 
  we check all communication issues and there is there is open
  communication
  between the jboss machine and my machine through the specified UDP
 port.
 
  is there any special jar need for UDPAppender ?
  or special log4j version ?
  i'm quite in the dark here, and couldn't find lots of information
 about
  UDPAppender on the net.
 
  any help is appreciated.
 
  thanks,
  Roy.
 
  --
  View this message in context:
 
 http://old.nabble.com/can%27t-get-UDPAppender-to-work-tp30919617p30919617.html
  Sent from the Log4j - Users mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
  For additional commands, e-mail: log4j-user-h...@logging.apache.org
 
 
 
 

 --
 View this message in context:
 http://old.nabble.com/can%27t-get-UDPAppender-to-work-tp30919617p30922474.html
 Sent from the Log4j - Users mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
 For additional commands, e-mail: log4j-user-h...@logging.apache.org


 
 

-- 
View this message in context: 
http://old.nabble.com/can%27t-get-UDPAppender-to-work-tp30919617p30932638.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: can't get UDPAppender to work

2011-02-15 Thread rvarum

thanks for you answer Rodney. 

i'm little lost with Java. 

i took PortBased.java , NetworkBased.java and UDPAppender.java from the svn 
and made 3 jars from them using:  jar cf file.jar file.java 
i put the 3 jars in the lib folder of the jboss where log4j.lib is, but it
didn't help. 
i also moved the appender section above the root element. 

am i in the right direction? 
should i create a jar with special names?  1 jar?  3 jars? 

i know its a little bit out of the scope here, but i really dont know where
to go from here. 

Thanks, 
Roy. 

P.S. - sorry everyone for the duplicated post.


Rodney Beede-5 wrote:
 
 You will need additional jars in order to that appender with a Java
 application.
 http://logging.apache.org/log4j/companions/receivers/apidocs/org/apache/log4j/net/UDPAppender.html
 Note that there is also log4jnet which has this appender for .NET
 applications so don't confuse them.
 
 http://logging.apache.org/log4j/companions/receivers/apidocs/org/apache/log4j/net/UDPAppender.htmlThe
 log4j companions receiver package hasn't been released yet.  You can get
 the
 source from
 http://svn.apache.org/repos/asf/logging/log4j/companions/receivers/trunk/
 and
 build it yourself.  I can't find any jars of it in any Maven repos.
 
 Additionally your UDP appender should probably be above the root element.
 
 On Mon, Feb 14, 2011 at 7:59 AM, rvarum r...@supportspace.com wrote:
 

 i think i did that.

 i attached a copy of the entire xml.
 http://old.nabble.com/file/p30922474/jboss-log4j.xml jboss-log4j.xml


 Rodney Beede-5 wrote:
 
  You probably forgot to add the appender to your root.  A complete copy
 of
  your log4j.xml would help.
 
  On Mon, Feb 14, 2011 at 1:49 AM, rvarum r...@supportspace.com wrote:
 
 
  Hi all,
 
  i'm an automation developer with QTP (not java developer)
 
  i'm trying to configure the log4j of our application to broadcast the
 log
  messages through UDP protocol using the UDPAppender, so i can't catch
 and
  process log messages.
 
  the application uses log4j version 1.2.16.
  this is the appender configuration i'm using in the log4j xml conf:
 
   appender name=QtpUdpAppender
  class=org.apache.log4j.net.UDPAppender
 
 
 
 layout class=org.apache.log4j.xml.XMLLayout
 
 /layout
   /appender
 
 
  i used several tools and log4j consoles in order to listen to the UDP
  port
  on my machine.
  i'm getting nothing from the jboss on that port.
 
  we check all communication issues and there is there is open
  communication
  between the jboss machine and my machine through the specified UDP
 port.
 
  is there any special jar need for UDPAppender ?
  or special log4j version ?
  i'm quite in the dark here, and couldn't find lots of information
 about
  UDPAppender on the net.
 
  any help is appreciated.
 
  thanks,
  Roy.
 
  --
  View this message in context:
 
 http://old.nabble.com/can%27t-get-UDPAppender-to-work-tp30919617p30919617.html
  Sent from the Log4j - Users mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
  For additional commands, e-mail: log4j-user-h...@logging.apache.org
 
 
 
 

 --
 View this message in context:
 http://old.nabble.com/can%27t-get-UDPAppender-to-work-tp30919617p30922474.html
 Sent from the Log4j - Users mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
 For additional commands, e-mail: log4j-user-h...@logging.apache.org


 
 

-- 
View this message in context: 
http://old.nabble.com/can%27t-get-UDPAppender-to-work-tp30919617p30932643.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: can't get UDPAppender to work

2011-02-15 Thread Rodney Beede
You will have to compile all the code and create a jar with the compiled
code.  All the correct paths inside the jar also need to be included.  If
you aren't familiar with using Java to compile code you may need to find a
Java developer to do so for you.  The project uses maven so you could build
it yourself.

Download Maven.  Download Java JDK.  Put the bin/ directories for both in
your path at a command prompt.

svn co
http://svn.apache.org/viewvc/logging/log4j/companions/receivers/trunk/

cd trunk/

mvn clean package

If you're lucky then look in the trunk/target folder for the needed jar.

This project just seems abandoned so it may not even work.


On Tue, Feb 15, 2011 at 9:35 AM, rvarum r...@supportspace.com wrote:


 thanks for you answer Rodney.

 i'm little lost with Java.

 i took PortBased.java , NetworkBased.java and UDPAppender.java from the svn
 and made 3 jars from them using:  jar cf file.jar file.java
 i put the 3 jars in the lib folder of the jboss where log4j.lib is, but
 it
 didn't help.
 i also moved the appender section above the root element.

 am i in the right direction?
 should i create a jar with special names?  1 jar?  3 jars?

 i know its a little bit out of the scope here, but i really dont know where
 to go from here.

 Thanks,
 Roy.

 P.S. - sorry everyone for the duplicated post.


 Rodney Beede-5 wrote:
 
  You will need additional jars in order to that appender with a Java
  application.
 
 http://logging.apache.org/log4j/companions/receivers/apidocs/org/apache/log4j/net/UDPAppender.html
  Note that there is also log4jnet which has this appender for .NET
  applications so don't confuse them.
 
  
 http://logging.apache.org/log4j/companions/receivers/apidocs/org/apache/log4j/net/UDPAppender.html
 The
  log4j companions receiver package hasn't been released yet.  You can get
  the
  source from
 
 http://svn.apache.org/repos/asf/logging/log4j/companions/receivers/trunk/
  and
  build it yourself.  I can't find any jars of it in any Maven repos.
 
  Additionally your UDP appender should probably be above the root element.
 
  On Mon, Feb 14, 2011 at 7:59 AM, rvarum r...@supportspace.com wrote:
 
 
  i think i did that.
 
  i attached a copy of the entire xml.
  http://old.nabble.com/file/p30922474/jboss-log4j.xml jboss-log4j.xml
 
 
  Rodney Beede-5 wrote:
  
   You probably forgot to add the appender to your root.  A complete copy
  of
   your log4j.xml would help.
  
   On Mon, Feb 14, 2011 at 1:49 AM, rvarum r...@supportspace.com
 wrote:
  
  
   Hi all,
  
   i'm an automation developer with QTP (not java developer)
  
   i'm trying to configure the log4j of our application to broadcast the
  log
   messages through UDP protocol using the UDPAppender, so i can't catch
  and
   process log messages.
  
   the application uses log4j version 1.2.16.
   this is the appender configuration i'm using in the log4j xml conf:
  
appender name=QtpUdpAppender
   class=org.apache.log4j.net.UDPAppender
  
  
  
  layout class=org.apache.log4j.xml.XMLLayout
  
  /layout
/appender
  
  
   i used several tools and log4j consoles in order to listen to the UDP
   port
   on my machine.
   i'm getting nothing from the jboss on that port.
  
   we check all communication issues and there is there is open
   communication
   between the jboss machine and my machine through the specified UDP
  port.
  
   is there any special jar need for UDPAppender ?
   or special log4j version ?
   i'm quite in the dark here, and couldn't find lots of information
  about
   UDPAppender on the net.
  
   any help is appreciated.
  
   thanks,
   Roy.
  
   --
   View this message in context:
  
 
 http://old.nabble.com/can%27t-get-UDPAppender-to-work-tp30919617p30919617.html
   Sent from the Log4j - Users mailing list archive at Nabble.com.
  
  
   -
   To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
   For additional commands, e-mail: log4j-user-h...@logging.apache.org
  
  
  
  
 
  --
  View this message in context:
 
 http://old.nabble.com/can%27t-get-UDPAppender-to-work-tp30919617p30922474.html
  Sent from the Log4j - Users mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
  For additional commands, e-mail: log4j-user-h...@logging.apache.org
 
 
 
 

 --
 View this message in context:
 http://old.nabble.com/can%27t-get-UDPAppender-to-work-tp30919617p30932643.html
 Sent from the Log4j - Users mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
 For additional commands, e-mail: log4j-user-h...@logging.apache.org




Re: can't get UDPAppender to work

2011-02-15 Thread Scott Deboy
It's not abandoned, the receivers companion is terribly overdue for a
release.

Chainsaw is also terribly overdue for a release, and relies on the receivers
companion.  Hopefully both will be released soon..

Scott

On Tue, Feb 15, 2011 at 10:02 AM, Rodney Beede
mailingl...@rodneybeede.comwrote:

 You will have to compile all the code and create a jar with the compiled
 code.  All the correct paths inside the jar also need to be included.  If
 you aren't familiar with using Java to compile code you may need to find a
 Java developer to do so for you.  The project uses maven so you could build
 it yourself.

 Download Maven.  Download Java JDK.  Put the bin/ directories for both in
 your path at a command prompt.

 svn co
 http://svn.apache.org/viewvc/logging/log4j/companions/receivers/trunk/

 cd trunk/

 mvn clean package

 If you're lucky then look in the trunk/target folder for the needed jar.

 This project just seems abandoned so it may not even work.


 On Tue, Feb 15, 2011 at 9:35 AM, rvarum r...@supportspace.com wrote:

 
  thanks for you answer Rodney.
 
  i'm little lost with Java.
 
  i took PortBased.java , NetworkBased.java and UDPAppender.java from the
 svn
  and made 3 jars from them using:  jar cf file.jar file.java
  i put the 3 jars in the lib folder of the jboss where log4j.lib is, but
  it
  didn't help.
  i also moved the appender section above the root element.
 
  am i in the right direction?
  should i create a jar with special names?  1 jar?  3 jars?
 
  i know its a little bit out of the scope here, but i really dont know
 where
  to go from here.
 
  Thanks,
  Roy.
 
  P.S. - sorry everyone for the duplicated post.
 
 
  Rodney Beede-5 wrote:
  
   You will need additional jars in order to that appender with a Java
   application.
  
 
 http://logging.apache.org/log4j/companions/receivers/apidocs/org/apache/log4j/net/UDPAppender.html
   Note that there is also log4jnet which has this appender for .NET
   applications so don't confuse them.
  
   
 
 http://logging.apache.org/log4j/companions/receivers/apidocs/org/apache/log4j/net/UDPAppender.html
  The
   log4j companions receiver package hasn't been released yet.  You can
 get
   the
   source from
  
 
 http://svn.apache.org/repos/asf/logging/log4j/companions/receivers/trunk/
   and
   build it yourself.  I can't find any jars of it in any Maven repos.
  
   Additionally your UDP appender should probably be above the root
 element.
  
   On Mon, Feb 14, 2011 at 7:59 AM, rvarum r...@supportspace.com wrote:
  
  
   i think i did that.
  
   i attached a copy of the entire xml.
   http://old.nabble.com/file/p30922474/jboss-log4j.xml jboss-log4j.xml
  
  
   Rodney Beede-5 wrote:
   
You probably forgot to add the appender to your root.  A complete
 copy
   of
your log4j.xml would help.
   
On Mon, Feb 14, 2011 at 1:49 AM, rvarum r...@supportspace.com
  wrote:
   
   
Hi all,
   
i'm an automation developer with QTP (not java developer)
   
i'm trying to configure the log4j of our application to broadcast
 the
   log
messages through UDP protocol using the UDPAppender, so i can't
 catch
   and
process log messages.
   
the application uses log4j version 1.2.16.
this is the appender configuration i'm using in the log4j xml conf:
   
 appender name=QtpUdpAppender
class=org.apache.log4j.net.UDPAppender
   
   
   
   layout class=org.apache.log4j.xml.XMLLayout
   
   /layout
 /appender
   
   
i used several tools and log4j consoles in order to listen to the
 UDP
port
on my machine.
i'm getting nothing from the jboss on that port.
   
we check all communication issues and there is there is open
communication
between the jboss machine and my machine through the specified UDP
   port.
   
is there any special jar need for UDPAppender ?
or special log4j version ?
i'm quite in the dark here, and couldn't find lots of information
   about
UDPAppender on the net.
   
any help is appreciated.
   
thanks,
Roy.
   
--
View this message in context:
   
  
 
 http://old.nabble.com/can%27t-get-UDPAppender-to-work-tp30919617p30919617.html
Sent from the Log4j - Users mailing list archive at Nabble.com.
   
   
   
 -
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail:
 log4j-user-h...@logging.apache.org
   
   
   
   
  
   --
   View this message in context:
  
 
 http://old.nabble.com/can%27t-get-UDPAppender-to-work-tp30919617p30922474.html
   Sent from the Log4j - Users mailing list archive at Nabble.com.
  
  
   -
   To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
   For additional commands, e-mail: log4j-user-h...@logging.apache.org
  
  
  
  
 
  --
  View this message in context:
 
 

RE: Custom EvaluatorClass with SMTPAppender when returning true sends PREVIOUS log message

2011-02-15 Thread Papierman, Paul
Seems that someone has already experienced this issue - I supposed that this 
hasn't been addressed:
http://marc.info/?l=log4j-userm=102507881420128w=2
http://marc.info/?l=log4j-userm=102508470025094w=2
http://marc.info/?l=log4j-userm=102508495925248w=2
(from 2002)

In a nutshell, what's happening is the event is added to the cycle buffer 
before the Evaluator class is checked.
So even though I set the threshold for the SMTP appender to ERROR, the previous 
one in the cycle buffer will be returned under the circumstances I described.
By setting the buffersize=1 I did solve the problem, but I will lose some 
context in the email sent.



From: Papierman, Paul
Sent: Tuesday, February 15, 2011 11:34 AM
To: 'log4j-user@logging.apache.org'
Subject: Custom EvaluatorClass with SMTPAppender when returning true sends 
PREVIOUS log message


1)  I've created a custom Evaluator class that I wish to use for the 
SMTPAppender to not send the same emails for errors over a period of time.


2)  I've added it to my log4j.xml configuration:
   !-- Buffer events and log them asynchronously --
   appender name=ASYNC class=org.apache.log4j.AsyncAppender
 errorHandler class=org.jboss.logging.util.OnlyOnceErrorHandler/
 appender-ref ref=FILE/
 appender-ref ref=CONSOLE/
 appender-ref ref=SMTP/
   /appender


   !-- EMail events to an administrator --
   appender name=SMTP class=org.apache.log4j.net.SMTPAppender
 errorHandler class=org.jboss.logging.util.OnlyOnceErrorHandler/
 !-- this is our custom TriggeringEventEvaluator --
 param name=EvaluatorClass 
value=com.somewhere.log4j.LimitingTriggeringEventEvaluator/
 param name=Threshold value=ERROR/
 param name=To 
value=myem...@somewhere.commailto:myem...@somewhere.com/
 param name=From 
value=lo...@somewhere.commailto:lo...@somewhere.com/
 param name=Subject value=LOCALHOST NODE1/
 param name=SMTPHost value=smtp.somewhere.com/
 param name=BufferSize value=100/
 layout class=org.apache.log4j.PatternLayout
   param name=ConversionPattern value=[%d{ABSOLUTE},%c{1}] %m%n/
 /layout
   /appender


3)  I know it's working because I log (via STDOUT) and I can see that 
isTriggeringEvent is returning false (appropriately) when the same message 
appears within a time interval. (I tried using LogLog but it doesn't seem to 
work with JBoss - that's another story)



4)  Most times when I log that I'm returning true (from isTriggeringEvent) 
because the message is a unique one what I receive via email is the Text from a 
PREVIOUS message.



-It sounds like the SMTPAppender Buffer is not working the way its 
supposed to - or there are multiple 'buffers' being created per JVM?

-Or is the issue the ASYNC aspect of how the messages are being logged?



In any case its definitely not working as expected. When I return true in 
isTriggeringEvent, I want to send an email for the message referenced in the 
LoggingEvent that I just evaluated.



Here's what's happening:

1 = boot application, my internal table is empty so all messages are 'new'

2 - log.error(AAA)  - isTriggeringEvent retrurns true, this results in an 
email sent with AAA as the contents which is correct

3 - log.error(AAA)  - isTriggeringEvent retrurns false, this results in no 
email sent which is correct since AAA has occurred already

4 - log.error(BBB)  - isTriggeringEvent retrurns true, which is correct since 
BBB has not been sent yet. But the email that I receive has the message (AAA) 
which is incorrect. It should have the contents of the evaluated message, BBB



Any help?





Notice: This e-mail message, together with any attachments, contains 
information of eRT that may be confidential, proprietary copyrighted and/or 
legally privileged, and is intended solely for the use of the individual or 
entity named on this message. If you are not the intended recipient, and have 
received this message in error, please immediately return this by e-mail and 
then delete it.