You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Kannan G <ka...@gmail.com> on 2011/03/02 22:47:07 UTC

Logging only specific number of lines

Hi

Since my application is in integration platform(Fuse) log files grow easily,
so we thought of controlling it by logging only specific number of lines
whenever exceptions are thrown. Is this possible with log4j to log specific
number of lines say 30 lines only instead entire stacktrace?

Also i have a requirement of logging fatal errors to syslog and application
exceptions to separate file. Is this possible to let log4j categorize the
error and send to different logs? Or any standard of way of doing this.

Thanks.
Kann

Re: Logging only specific number of lines

Posted by Martin Nyolt <a3...@freenet.de>.
Hello

Am 02.03.2011 22:47, schrieb Kannan G:
> Hi
>
> Since my application is in integration platform(Fuse) log files grow easily,
> so we thought of controlling it by logging only specific number of lines
> whenever exceptions are thrown. Is this possible with log4j to log specific
> number of lines say 30 lines only instead entire stacktrace?

I don't know of any option for that, but you can easily write your own appender, inheriting the one you are using at the moment.

> Also i have a requirement of logging fatal errors to syslog and application
> exceptions to separate file. Is this possible to let log4j categorize the
> error and send to different logs? Or any standard of way of doing this.

Of course you can specify a seperate syslog appender and set the level to FATAL.  (Am I missing anything?)
The same is true for a FileAppender with a level of ERROR (or whatever level exceptions are) - but I assume that your true problem is, that you want to filter out all events with no Throwable attached to it?
In this case you could also writea new Filter which does just that and append it to the FileAppender.


Best regards,
Martin

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


Re: Logging only specific number of lines

Posted by Curt Arnold <ca...@apache.org>.
You can configure either one of the built-in throwable renderers or provide your own.  Look at tests/input/xml/throwableRenderer1.xml for an example of configuration.  See org.apache.log4j.EnhancedThrowableRenderer (http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/EnhancedThrowableRenderer.html) for options.

One the second, attach the SyslogAppender to the root logger, but set the threshold on the appender to Fatal.  

Note: SyslogAppender uses sockets to talk with the syslog daemon.  Network (even on same machine) access to the syslog is often disabled by default.




On Mar 2, 2011, at 3:47 PM, Kannan G wrote:

> Hi
> 
> Since my application is in integration platform(Fuse) log files grow easily,
> so we thought of controlling it by logging only specific number of lines
> whenever exceptions are thrown. Is this possible with log4j to log specific
> number of lines say 30 lines only instead entire stacktrace?
> 
> Also i have a requirement of logging fatal errors to syslog and application
> exceptions to separate file. Is this possible to let log4j categorize the
> error and send to different logs? Or any standard of way of doing this.
> 
> Thanks.
> Kann


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