Re: Multiple appenders and verbose logging for specific classes for an appender

2013-10-02 Thread fedinho
Thanks for your response Jacob.

I've been looking at the additive feature, but I'm not sure it solves my
requirement.

Given this configuration, I would like to debug class X on appender A, but
still keep the info level messages from class X on appender B.

I was hoping that this line would make this happen, but doesn't seem to
work.
log4j.logger.classX=debug, A

Is there a simple example similar to my requirements somewhere?

Thanks
Fredrik


On Tue, Oct 1, 2013 at 6:50 PM, Jacob Kjome h...@visi.com wrote:

 On Tue, 1 Oct 2013 18:17:41 +0200
  fedinho fedi...@gmail.com wrote:

 Hi.

 A simple question I hope someone can help me with. This is using log4j
 1.2.x

 I would like to log info level to one appender A and warn level to another
 appenderB.

 However, I would like to log debug messages from class X to appender A,
 and
 debug messages from class Y to appender B.

 Thanks for any tips for a configuration that will work. Threshold is not
 the way to go. Is there a way A and B can have different root loggers or
 categories?


 This is usually done by setting the logger additivity to false for
 either the logger in question or one it inherits from, which essentially
 makes the logger with additivity=false the root logger for all inheritors.
 See...

 http://logging.apache.org/**log4j/1.2/manual.html#**Appenders_and_Layoutshttp://logging.apache.org/log4j/1.2/manual.html#Appenders_and_Layouts


  Kind regards
 Fredrik



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




Re: Multiple appenders and verbose logging for specific classes for an appender

2013-10-02 Thread Remko Popma
By default, if you set the level of a logger/appender to debug, it will
process debug, info, warn, error and fatal messages.

Is this what you want, or do you want to include only debug-level messages,
and exclude info, warn, error and fatal messages?

On Wednesday, October 2, 2013, fedinho wrote:

 Thanks for your response Jacob.

 I've been looking at the additive feature, but I'm not sure it solves my
 requirement.

 Given this configuration, I would like to debug class X on appender A, but
 still keep the info level messages from class X on appender B.

 I was hoping that this line would make this happen, but doesn't seem to
 work.
 log4j.logger.classX=debug, A

 Is there a simple example similar to my requirements somewhere?

 Thanks
 Fredrik


 On Tue, Oct 1, 2013 at 6:50 PM, Jacob Kjome h...@visi.com javascript:;
 wrote:

  On Tue, 1 Oct 2013 18:17:41 +0200
   fedinho fedi...@gmail.com javascript:; wrote:
 
  Hi.
 
  A simple question I hope someone can help me with. This is using log4j
  1.2.x
 
  I would like to log info level to one appender A and warn level to
 another
  appenderB.
 
  However, I would like to log debug messages from class X to appender A,
  and
  debug messages from class Y to appender B.
 
  Thanks for any tips for a configuration that will work. Threshold is not
  the way to go. Is there a way A and B can have different root loggers or
  categories?
 
 
  This is usually done by setting the logger additivity to false for
  either the logger in question or one it inherits from, which essentially
  makes the logger with additivity=false the root logger for all
 inheritors.
  See...
 
 
 http://logging.apache.org/**log4j/1.2/manual.html#**Appenders_and_Layouts
 http://logging.apache.org/log4j/1.2/manual.html#Appenders_and_Layouts
 
 
   Kind regards
  Fredrik
 
 
 
  --**--**-
  To unsubscribe, e-mail: log4j-user-unsubscribe@**logging.apache.org
 log4j-user-unsubscr...@logging.apache.org javascript:;
  For additional commands, e-mail: log4j-user-help@logging.**apache.org
 log4j-user-h...@logging.apache.org javascript:;
 
 



Re: Multiple appenders and verbose logging for specific classes for an appender

2013-10-02 Thread fedinho
Hi.

No, I do not want to exclude the more severe logging levels, but I want to
enable more verbose logging for specific classes for appender A
independently of appender Bs logging of those same classes, and vice versa:

Appender A and B is defined.
Appender A is logging INFO+ for all by default, while appender B is logging
WARN+ for all.
Class X is logging DEBUG+more severe levels through appender A, but still
logging WARN+more severe levels through appender B.
Class Y is logging DEBUG+more severe levels through appender B, but still
logging INFO+more severe levels through appender A.
+ means including more severe logging levels

Thanks
Fredrik


On Wed, Oct 2, 2013 at 9:35 AM, Remko Popma remko.po...@gmail.com wrote:

 By default, if you set the level of a logger/appender to debug, it will
 process debug, info, warn, error and fatal messages.

 Is this what you want, or do you want to include only debug-level messages,
 and exclude info, warn, error and fatal messages?

 On Wednesday, October 2, 2013, fedinho wrote:

  Thanks for your response Jacob.
 
  I've been looking at the additive feature, but I'm not sure it solves my
  requirement.
 
  Given this configuration, I would like to debug class X on appender A,
 but
  still keep the info level messages from class X on appender B.
 
  I was hoping that this line would make this happen, but doesn't seem to
  work.
  log4j.logger.classX=debug, A
 
  Is there a simple example similar to my requirements somewhere?
 
  Thanks
  Fredrik
 
 
  On Tue, Oct 1, 2013 at 6:50 PM, Jacob Kjome h...@visi.comjavascript:;
  wrote:
 
   On Tue, 1 Oct 2013 18:17:41 +0200
fedinho fedi...@gmail.com javascript:; wrote:
  
   Hi.
  
   A simple question I hope someone can help me with. This is using log4j
   1.2.x
  
   I would like to log info level to one appender A and warn level to
  another
   appenderB.
  
   However, I would like to log debug messages from class X to appender
 A,
   and
   debug messages from class Y to appender B.
  
   Thanks for any tips for a configuration that will work. Threshold is
 not
   the way to go. Is there a way A and B can have different root loggers
 or
   categories?
  
  
   This is usually done by setting the logger additivity to false for
   either the logger in question or one it inherits from, which
 essentially
   makes the logger with additivity=false the root logger for all
  inheritors.
   See...
  
  
 
 http://logging.apache.org/**log4j/1.2/manual.html#**Appenders_and_Layouts
  http://logging.apache.org/log4j/1.2/manual.html#Appenders_and_Layouts
  
  
Kind regards
   Fredrik
  
  
  
  
 --**--**-
   To unsubscribe, e-mail: log4j-user-unsubscribe@**logging.apache.org
  log4j-user-unsubscr...@logging.apache.org javascript:;
   For additional commands, e-mail: log4j-user-help@logging.**apache.org
  log4j-user-h...@logging.apache.org javascript:;
  
  
 



Re: epoch time format for logging

2013-10-02 Thread Gary Gregory
On Tue, Oct 1, 2013 at 1:08 PM, Gary Gregory garydgreg...@gmail.com wrote:

 I create a JIRA to track possible solutions:
 https://issues.apache.org/jira/browse/LOG4J2-415

 I have attached two different solutions in a patch file.


I reworked the code in the date converter solution to be more OO. This is
now in SVN. Use %d{UNIX} and %d{UNIX_MILLIS}. I updated the manual in SVN
as well.

Gary



 Gary


 On Mon, Sep 30, 2013 at 11:33 PM, Gary Gregory garydgreg...@gmail.comwrote:

 Hello Ed,

 This is what Log4j 2 can do now WRT to time stamp formatting:
 https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout

 When you say epoch time, do you mean simply that you would like to use
 the result of java.lang.System.currentTimeMillis() ?

 Gary


 On Mon, Sep 30, 2013 at 8:30 PM, Edward Peschko horo...@gmail.comwrote:

 All,

 For reasons of simplicity  consistency, I would like to have my logs
 have epoch time (plus milliseconds) as their format. I figure:

 1. this should be the most efficient way to get a timestamp
 2. it is completely clear - unlike local time, or partial times (eg.
 HH:MM:SS) there is no question of exactly when the event occurred.
 3. it is concise - only taking 10 (or 14 with ms timestamp) characters.
 4. it is exceedingly easy to do date arithmetic with it
 5. it can searched as a number hence finding ranges in which events
 occured in very large files is a simple, binary search.

 Anyways, looking through the docs for log4j, I didn't see any docs on
 how to do this. Is it possible, and if not currently possible, how
 easy would it be to add it?

 Again, I'd like to standardize all my logs on this, so any info on how
 to do it is appreciated..

 Thanks much,

 Ed

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




 --
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second 
 Editionhttp://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory




 --
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second 
 Editionhttp://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory




-- 
E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
Java Persistence with Hibernate, Second Editionhttp://www.manning.com/bauer3/
JUnit in Action, Second Edition http://www.manning.com/tahchiev/
Spring Batch in Action http://www.manning.com/templier/
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory


Re: Multiple appenders and verbose logging for specific classes for an appender

2013-10-02 Thread Jacob Kjome


Apply appenderA and AppenderB to the root logger.  I always set the root 
logger level to WARN to avoid trace/debug/info messages from arbitrary 
libraries.


Then, if you want INFO logging for most of your library, configure the lowest 
common denominator package for your app, let's say com.myapp, for the INFO 
level.


Now configure the ClassX and ClassY loggers for the DEBUG level.

Now your requirements get complicated.  You need to configure filters for both 
appenders so that:


1. AppenderB explicitly ignores anything but WARN+, except when logging for 
ClassY, in which case it should accept DEBUG+.
2. AppenderA accepts whatever is sent to it except when logging for ClassY, in 
which case it should only accept INFO+


You can roll your own filter by implementing the Filter interface [1] or you 
could try the extras [2] ExpressionFilter [3].  I'm not an expert on supported 
expressions, but you can search for examples, such as [4].


This is an awfully complicated setup.  I hope this is just about theory and 
not the way you actually intend to use Log4j.  Nevertheless, Log4j should be 
able to handle it.



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

[2] http://logging.apache.org/log4j/companions/extras/index.html
[3] 
http://svn.apache.org/repos/asf/logging/site/trunk/docs/log4j/companions/extras/apidocs/org/apache/log4j/filter/ExpressionFilter.html
[4] 
http://apache-logging.6191.n7.nabble.com/Multiple-expressions-define-in-one-ExpressionFilter-td7229.html



Jake

On Wed, 2 Oct 2013 11:16:42 +0200
 fedinho fedi...@gmail.com wrote:

Hi.

No, I do not want to exclude the more severe logging levels, but I want to
enable more verbose logging for specific classes for appender A
independently of appender Bs logging of those same classes, and vice versa:

Appender A and B is defined.
Appender A is logging INFO+ for all by default, while appender B is logging
WARN+ for all.
Class X is logging DEBUG+more severe levels through appender A, but still
logging WARN+more severe levels through appender B.
Class Y is logging DEBUG+more severe levels through appender B, but still
logging INFO+more severe levels through appender A.
+ means including more severe logging levels

Thanks
Fredrik


On Wed, Oct 2, 2013 at 9:35 AM, Remko Popma remko.po...@gmail.com wrote:


By default, if you set the level of a logger/appender to debug, it will
process debug, info, warn, error and fatal messages.

Is this what you want, or do you want to include only debug-level messages,
and exclude info, warn, error and fatal messages?

On Wednesday, October 2, 2013, fedinho wrote:

 Thanks for your response Jacob.

 I've been looking at the additive feature, but I'm not sure it solves my
 requirement.

 Given this configuration, I would like to debug class X on appender A,
but
 still keep the info level messages from class X on appender B.

 I was hoping that this line would make this happen, but doesn't seem to
 work.
 log4j.logger.classX=debug, A

 Is there a simple example similar to my requirements somewhere?

 Thanks
 Fredrik


 On Tue, Oct 1, 2013 at 6:50 PM, Jacob Kjome h...@visi.comjavascript:;
 wrote:

  On Tue, 1 Oct 2013 18:17:41 +0200
   fedinho fedi...@gmail.com javascript:; wrote:
 
  Hi.
 
  A simple question I hope someone can help me with. This is using log4j
  1.2.x
 
  I would like to log info level to one appender A and warn level to
 another
  appenderB.
 
  However, I would like to log debug messages from class X to appender
A,
  and
  debug messages from class Y to appender B.
 
  Thanks for any tips for a configuration that will work. Threshold is
not
  the way to go. Is there a way A and B can have different root loggers
or
  categories?
 
 
  This is usually done by setting the logger additivity to false for
  either the logger in question or one it inherits from, which
essentially
  makes the logger with additivity=false the root logger for all
 inheritors.
  See...
 
 

http://logging.apache.org/**log4j/1.2/manual.html#**Appenders_and_Layouts
 http://logging.apache.org/log4j/1.2/manual.html#Appenders_and_Layouts
 
 
   Kind regards
  Fredrik
 
 
 
 
--**--**-
  To unsubscribe, e-mail: log4j-user-unsubscribe@**logging.apache.org
 log4j-user-unsubscr...@logging.apache.org javascript:;
  For additional commands, e-mail: log4j-user-help@logging.**apache.org
 log4j-user-h...@logging.apache.org javascript:;
 
 





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



Re: epoch time format for logging

2013-10-02 Thread Edward Peschko
Gary,

Thanks for this - it will be very, very useful for our project.

Ed

On Wed, Oct 2, 2013 at 7:53 AM, Gary Gregory garydgreg...@gmail.com wrote:
 On Tue, Oct 1, 2013 at 1:08 PM, Gary Gregory garydgreg...@gmail.com wrote:

 I create a JIRA to track possible solutions:
 https://issues.apache.org/jira/browse/LOG4J2-415

 I have attached two different solutions in a patch file.


 I reworked the code in the date converter solution to be more OO. This is
 now in SVN. Use %d{UNIX} and %d{UNIX_MILLIS}. I updated the manual in SVN
 as well.

 Gary



 Gary


 On Mon, Sep 30, 2013 at 11:33 PM, Gary Gregory garydgreg...@gmail.comwrote:

 Hello Ed,

 This is what Log4j 2 can do now WRT to time stamp formatting:
 https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout

 When you say epoch time, do you mean simply that you would like to use
 the result of java.lang.System.currentTimeMillis() ?

 Gary


 On Mon, Sep 30, 2013 at 8:30 PM, Edward Peschko horo...@gmail.comwrote:

 All,

 For reasons of simplicity  consistency, I would like to have my logs
 have epoch time (plus milliseconds) as their format. I figure:

 1. this should be the most efficient way to get a timestamp
 2. it is completely clear - unlike local time, or partial times (eg.
 HH:MM:SS) there is no question of exactly when the event occurred.
 3. it is concise - only taking 10 (or 14 with ms timestamp) characters.
 4. it is exceedingly easy to do date arithmetic with it
 5. it can searched as a number hence finding ranges in which events
 occured in very large files is a simple, binary search.

 Anyways, looking through the docs for log4j, I didn't see any docs on
 how to do this. Is it possible, and if not currently possible, how
 easy would it be to add it?

 Again, I'd like to standardize all my logs on this, so any info on how
 to do it is appreciated..

 Thanks much,

 Ed

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




 --
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second 
 Editionhttp://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory




 --
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second 
 Editionhttp://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory




 --
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second 
 Editionhttp://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory

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