Log messages in multithreaded applications

2011-09-04 Thread Antonio Rodriges
Hello,

In multithreaded applications I got messages like

2011-09-04/01:50:22.515/PDT [AwtEventQueue-1] INFO  Received: message

Thus,
 private final Logger LOG = Logger.getLogger(this.getClass());

this.getClass() does not really make sense?

How to enable log4j more specific what class makes the message in
multithreaded applications?
Also, is there any way to log automatically the name of a method?

Thank you

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



Re: Log messages in multithreaded applications

2011-09-04 Thread Tim Watts
See:

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html

you want the %c specifier in your log4j configuration for the layout.

If each of the classes that will be logging has (or inherits) an
initializer like the one you mentioned then this.getClass() actually
does make sense. Although being private, of course, means it will be
inaccessible to subclasses.


On Sun, 2011-09-04 at 01:53 -0700, Antonio Rodriges wrote:
 Hello,
 
 In multithreaded applications I got messages like
 
 2011-09-04/01:50:22.515/PDT [AwtEventQueue-1] INFO  Received: message
 
 Thus,
  private final Logger LOG = Logger.getLogger(this.getClass());
 
 this.getClass() does not really make sense?
 
 How to enable log4j more specific what class makes the message in
 multithreaded applications?
 Also, is there any way to log automatically the name of a method?
 
 Thank you
 
 -
 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 messages in multithreaded applications

2011-09-04 Thread Jacob Kjome

See PatternLayout javadoc [1].  In any case, I think getLogger(Class) just 
creates
confusion.  It was added as a convenience because of the way most people name
their loggers, using the package/class hierarchy.  But really a logger name is
just a string and getLogger(String) would have been sufficient (using
getClass().getName()) and less confusing as it would have made clear to users 
that
package/class is only one approach to naming loggers, not the only one.


[1] 
http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html


Jake

On 9/4/2011 2:53 AM, Antonio Rodriges wrote:
 Hello,
 
 In multithreaded applications I got messages like
 
 2011-09-04/01:50:22.515/PDT [AwtEventQueue-1] INFO  Received: message
 
 Thus,
  private final Logger LOG = Logger.getLogger(this.getClass());
 
 this.getClass() does not really make sense?
 
 How to enable log4j more specific what class makes the message in
 multithreaded applications?
 Also, is there any way to log automatically the name of a method?
 
 Thank you
 
 -
 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: Changing Level of Logging during runtime

2011-09-04 Thread Jacob Kjome

There used to be a nice open source, Struts-based, Log4j configuration app out
there, but it seems to have disappeared.  There's a simple one in the
Log4j-sandbox you can try...

http://svn.apache.org/repos/asf/logging/sandbox/log4j/log4j_sandbox/tags/LOG4J_SANDBOX_ALPHA3/src/java/org/apache/log4j/servlet/ConfigurationServlet.java


Note that I specifically point to the tag LOG4J_SANDBOX_ALPHA3 because later
tags were based on the now defunct Log4j-1.3 codebase and the trunk, I believe,
continues to be based on the said defunct codebase.


Jake

On 9/2/2011 2:58 AM, Amitabh78 wrote:
 
 Hi, I want to change the level og logging during runtime. The change in level
 should be in immediate effect i.e. when admin changes the level og logging
 from Debug to Info through UI Screen, the logging at debug level should be
 stopped immediately.
 
 

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



Re: Log messages in multithreaded applications

2011-09-04 Thread Antonio Rodriges
Thank you, Tim and Jacob, the option %c and link for PatternLayout helped.

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