AW: Log Debug and Info in 2 different files

2009-02-16 Thread Bender Heri
I think it is not necessary to use Filters as Curt suggested since you dont 
want to have an upper limit of the levels. Add the threshold property to the 
appender declaration. 
Your problem is that you have defined two loggers with the same name. I assume 
that the second one overwrites the first one during configuration. Just declare 
one logger (without level property) and attach both appenders to it. BTW: You 
should also declare a root logger for all other log statements.

   


   

Heri 

-Ursprüngliche Nachricht-
Von: Mohit Anchlia [mailto:mohitanch...@gmail.com] 
Gesendet: Donnerstag, 12. Februar 2009 23:30
An: log4j-user@logging.apache.org
Betreff: [SPAM (Bayesain Analysis)] - Log Debug and Info in 2 different files - 
Bayesian Filter detected spam

I am trying to log DEBUG and up in one log file and INFO and up in other log 
file. But it doesn't seem to be working. I have tried various things like 
"Level", "Threshold", "additivity", "Priority"
etc. Nothing seems to be working. Nothing is being written to sw.log.
Only INFO and up is being written to sw_infoerr.log.

I just want DEBUG and up in sw.log and INFO and up in sw_infoerr.log

Below is the config:




http://jakarta.apache.org/log4j/";
debug="false">
   
  
  

  
  
  

  
  
 
  
   
   
  
  

  
  
  

  
  
 
  
   

   

   

   


   


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



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



Re: Log Debug and Info in 2 different files

2009-02-16 Thread Curt Arnold


On Feb 12, 2009, at 5:30 PM, Mohit Anchlia wrote:


I am trying to log DEBUG and up in one log file and INFO and up in
other log file. But it doesn't seem to be working. I have tried
various things like "Level", "Threshold", "additivity", "Priority"
etc. Nothing seems to be working. Nothing is being written to sw.log.
Only INFO and up is being written to sw_infoerr.log.



Bender was right.  I didn't see the "and up" in the problem description.



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



Re: Log Debug and Info in 2 different files

2009-02-16 Thread Steve Cohen

I just want DEBUG and up in sw.log and INFO and up in sw_infoerr.log


Why would this not work?




http://jakarta.apache.org/log4j/";
debug="false">
  

...
  
  


...
 

  


  




Mohit Anchlia wrote:

I am trying to log DEBUG and up in one log file and INFO and up in
other log file. But it doesn't seem to be working. I have tried
various things like "Level", "Threshold", "additivity", "Priority"
etc. Nothing seems to be working. Nothing is being written to sw.log.
Only INFO and up is being written to sw_infoerr.log.

I just want DEBUG and up in sw.log and INFO and up in sw_infoerr.log

Below is the config:




http://jakarta.apache.org/log4j/";
debug="false">
   
  
  

  
  
  

  
  
 
  
   
   
  
  

  
  
  

  
  
 
  
   

   

   

   


   


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



  



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



sending output from separate java packages to separate files

2009-02-16 Thread Pat Farrell
I know this can be done, but I can't figure out how to configure
log4j.properties to send log messages from libraries/packages to
separate streams. I get all of my output in one log file.

I've read all of "The complete log4j manual" by Ceki Gülcü, and just
don't get it.
I want all msgs from com.baz.* to go one place,
all msgs from com.foo.* to go to another
all from net.sourceforge.stripes to go to a third.

the log4j file looks like:

   1. log4j.appender.stdout=org.apache.log4j.ConsoleAppender
   2. log4j.appender.stdout.Target=System.out
   3. log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
   4. log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p
%c{1}:%L - %m%n
   5.
   6. log4j.appender.baz=org.apache.log4j.FileAppender
   7. log4j.appender.baz.File=/tmp/baz.log
   8.
   9. log4j.appender.stripesfile=org.apache.log4j.FileAppender
  10. log4j.appender.stripesfile.File=/tmp/stripes.log
  11.
  12. log4j.appender.foo=org.apache.log4j.FileAppender
  13. log4j.appender.foo.File=/tmp/foo.log
  14. log4j.rootLogger=INFO, stdout, base
  15. log4j.logger.net.sourceforge.stripes=DEBUG, stdout, stripesfile
  16. log4j.logger.com.foo=DEBUG, stdout, fnfbookfile
  17. log4j.logger.com.baz=DEBUG, stdout, fnfbookfile


When I test it, it all goes to the same place

Test code looks like:


   1. Logger aLog =
Logger.getLogger("net.sourceforge.stripes.action.Resolution");
   2. aLog.error("this is an error");
   5. Logger cLog = Logger.getLogger("com.foo.busobj.Address");
   6. cLog.error("this is an error address");
   7. Logger dLog =
Logger.getLogger("com.baz.database.DBConnectionPool");
   8. dLog.error("this is an error DBConnPool");


Thanks

-- 
Pat Farrell
http://www.pfarrell.com/


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



Re: sending output from separate java packages to separate files

2009-02-16 Thread Curt Arnold


On Feb 16, 2009, at 3:54 PM, Pat Farrell wrote:


I know this can be done, but I can't figure out how to configure
log4j.properties to send log messages from libraries/packages to
separate streams. I get all of my output in one log file.

I've read all of "The complete log4j manual" by Ceki Gülcü, and just
don't get it.
I want all msgs from com.baz.* to go one place,
all msgs from com.foo.* to go to another
all from net.sourceforge.stripes to go to a third.

the log4j file looks like:

  1. log4j.appender.stdout=org.apache.log4j.ConsoleAppender
  2. log4j.appender.stdout.Target=System.out
  3. log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
  4. log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p
%c{1}:%L - %m%n
  5.
  6. log4j.appender.baz=org.apache.log4j.FileAppender
  7. log4j.appender.baz.File=/tmp/baz.log
  8.
  9. log4j.appender.stripesfile=org.apache.log4j.FileAppender
 10. log4j.appender.stripesfile.File=/tmp/stripes.log
 11.
 12. log4j.appender.foo=org.apache.log4j.FileAppender
 13. log4j.appender.foo.File=/tmp/foo.log
 14. log4j.rootLogger=INFO, stdout, base
 15. log4j.logger.net.sourceforge.stripes=DEBUG, stdout, stripesfile
 16. log4j.logger.com.foo=DEBUG, stdout, fnfbookfile
 17. log4j.logger.com.baz=DEBUG, stdout, fnfbookfile


When I test it, it all goes to the same place

Test code looks like:


  1. Logger aLog =
Logger.getLogger("net.sourceforge.stripes.action.Resolution");
  2. aLog.error("this is an error");
  5. Logger cLog = Logger.getLogger("com.foo.busobj.Address");
  6. cLog.error("this is an error address");
  7. Logger dLog =
Logger.getLogger("com.baz.database.DBConnectionPool");
  8. dLog.error("this is an error DBConnPool");


Thanks

--  
Pat Farrell

http://www.pfarrell.com/





You define appenders named "stdout", "baz" and "foo", then you attach  
appenders named "stdout", "base" and "stripesfile" to various  
loggers.  Since "base" and "stripesfile" are not defined, the only  
place for the messages to go is to "stdout".


Since you are not setting additivity to false, all messages sent to  
"com.foo.*" will be sent to stdout twice, once for its attachment at  
"com.foo" and once for its attachment to the rootLogger.




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



Re: Log4j with JMS/ActiveMQ

2009-02-16 Thread Paul Smith
[resending this because it appears to have been lost in the ether  
somehow]



I wrote a test case for JMSAppender that used ActiveMQ so I can show  
you how to get it to work:


See:

https://issues.apache.org/bugzilla/show_bug.cgi?id=38513

specifically, putting the jndi.properties that is attached here:

https://issues.apache.org/bugzilla/attachment.cgi?id=17590

as an example, should get you started with AMQ (I love AMQ! :) )

cheers,

Paul
On 12/02/2009, at 10:20 PM, Sylvester wrote:


Hi,
I've been trying to use Log4j with ActiveMQ. I have ActiveMQ running  
on my system. To setup log4j I use:


JMSAppender appender= new JMSAppender();
  appender.setName("JMSAppender");
  appender.setTopicBindingName("topic");
  appender.setTopicConnectionFactoryBindingName("");   //not  
sure what is supposed to go here

  appender.setLayout(patternLayout);
   
appender 
.setInitialContextFactoryName 
("org.apache.activemq.jndi.ActiveMQInitialContextFactory"); //is  
this right?
  appender.setURLPkgPrefixes("");  //not sure about this one  
either

  appender.setProviderURL( "tcp://localhost:61616");
  appender.activateOptions();


The appender.activateOptions(); line gives me:

log4j:ERROR Error while activating options for appender named  
[JMSAppender].

java.lang.NullPointerException
  at javax.naming.InitialContext.getURLScheme(Unknown Source)
  at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown  
Source)

  at javax.naming.InitialContext.lookup(Unknown Source)
  at org.apache.log4j.net.JMSAppender.lookup(Unknown Source)
  at org.apache.log4j.net.JMSAppender.activateOptions(Unknown Source)
  at com.Main.main(Main.java:83)

How do I fix this?

Thanks,
Sylvester

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



Paul Smith
Production Engineering Manager

Aconex
The easy way to save time and money on your project

696 Bourke Street, Melbourne,
VIC 3000, Australia
Tel: +61 3 9240 0200  Fax: +61 3 9240 0299
Email: psm...@aconex.com  www.aconex.com

This email and any attachments are intended solely for the addressee.  
The contents may be privileged, confidential and/or subject to  
copyright or other applicable law. No confidentiality or privilege is  
lost by an erroneous transmission. If you have received this e-mail in  
error, please let us know by reply e-mail and delete or destroy this  
mail and all copies. If you are not the intended recipient of this  
message you must not disseminate, copy or take any action in reliance  
on it. The sender takes no responsibility for the effect of this  
message upon the recipient's computer system.







Re: sending output from separate java packages to separate files

2009-02-16 Thread Pat Farrell
Curt Arnold wrote:
> You define appenders named "stdout", "baz" and "foo", then you attach
> appenders named

Thanks. I tried to edit the property file to protect the innocent, and
mangled it.

> Since "base" and "stripesfile" are not defined, the only place for the
> messages to go is to "stdout".

Actually, they were always going to one of the log files. But you
pointed me in the right direction.

Thanks

My real problem was that Netbeans was putting the log4j.properties file
in the sublibrary, and it was getting read first.


> Since you are not setting additivity to false, all messages sent to
> "com.foo.*" will be sent to stdout twice, once for its attachment at
> "com.foo" and once for its attachment to the rootLogger.

I've read and re-read the complete manual, and I think I get the concept
of "additivity" but I don't understand how to control them in the
properties file.

Is there a source for more examples of log4j.properties files and
options, syntax, etc?  The manual has lots more on XML formats and
controlling it from within Java than it has on simple properties.

Even the Wiki seems to not have much (or much I can find) on properties
files.

Where possible, I much prefer good ol Java properties files.

Thanks
Pat

-- 
Pat Farrell
http://www.pfarrell.com/


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



AW: Log Debug and Info in 2 different files

2009-02-16 Thread Bender Heri
What is the problem? The below configuration seems OK, if you replace the "..." 
by the other needed parameters (file, layout, etc).
You can put debug="true" to see on the console how log4j configures itself.
Heri 

-Ursprüngliche Nachricht-
Von: Steve Cohen [mailto:sco...@javactivity.org] 
Gesendet: Montag, 16. Februar 2009 19:50
An: Log4J Users List
Betreff: [SPAM (Bayesain Analysis)] - Re: Log Debug and Info in 2 different 
files - Bayesian Filter detected spam

>> I just want DEBUG and up in sw.log and INFO and up in sw_infoerr.log

Why would this not work?




http://jakarta.apache.org/log4j/";
debug="false">
   
 ...
   
   


...
  

   


   




Mohit Anchlia wrote:
> I am trying to log DEBUG and up in one log file and INFO and up in 
> other log file. But it doesn't seem to be working. I have tried 
> various things like "Level", "Threshold", "additivity", "Priority"
> etc. Nothing seems to be working. Nothing is being written to sw.log.
> Only INFO and up is being written to sw_infoerr.log.
>
> I just want DEBUG and up in sw.log and INFO and up in sw_infoerr.log
>
> Below is the config:
>
>   SYSTEM "log4j.dtd">
>
> http://jakarta.apache.org/log4j/";
> debug="false">
>
>   
>   
>
>   
>   
>   
>
>   
>   
>  
>   
>
>
>   
>   
>
>   
>   
>   
>
>   
>   
>  
>   
>
>
>
>   
>
>
>
> 
>   
>
> 
>
> -
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>
>
>   


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



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



AW: sending output from separate java packages to separate files

2009-02-16 Thread Bender Heri
Additivity in Properties file:

Log4j.additivity.=false

See also page 53 in Manual.

Heri 

-Ursprüngliche Nachricht-
Von: Pat Farrell [mailto:pfarr...@pfarrell.com] 
Gesendet: Dienstag, 17. Februar 2009 06:32
An: Log4J Users List
Betreff: [SPAM (Bayesain Analysis)] - Re: sending output from separate java 
packages to separate files - Bayesian Filter detected spam

Curt Arnold wrote:
> You define appenders named "stdout", "baz" and "foo", then you attach 
> appenders named

Thanks. I tried to edit the property file to protect the innocent, and mangled 
it.

> Since "base" and "stripesfile" are not defined, the only place for the 
> messages to go is to "stdout".

Actually, they were always going to one of the log files. But you pointed me in 
the right direction.

Thanks

My real problem was that Netbeans was putting the log4j.properties file in the 
sublibrary, and it was getting read first.


> Since you are not setting additivity to false, all messages sent to 
> "com.foo.*" will be sent to stdout twice, once for its attachment at 
> "com.foo" and once for its attachment to the rootLogger.

I've read and re-read the complete manual, and I think I get the concept of 
"additivity" but I don't understand how to control them in the properties file.

Is there a source for more examples of log4j.properties files and options, 
syntax, etc?  The manual has lots more on XML formats and controlling it from 
within Java than it has on simple properties.

Even the Wiki seems to not have much (or much I can find) on properties files.

Where possible, I much prefer good ol Java properties files.

Thanks
Pat

--
Pat Farrell
http://www.pfarrell.com/


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