You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Sudharma Puranik <su...@gmail.com> on 2013/10/09 19:25:54 UTC

Logging to Disk in case of only Error

Hello,

I have a special case of logging, that is , whenever I get an Error I would
want to log to disk. Kind of a Dump log. The approach I have used so far
are,

1. extend RollingRandomAccessAppender and RandomAccessManager and create my
own write method which will only write to a IO Stream and when error occurs
I flush it using ByteBuffer. But the problem is I am not able to get the
hook of Exception handling.

2 Tried to write my own NIO streaming with different thread. But handling
rollover is not managable.

Could you please suggest me a better approach for this?

-Sudharma

Re: Logging to Disk in case of only Error

Posted by Sudharma Puranik <su...@gmail.com>.
The need is that I would be appending the logging events to the Buffer,
 but would only write to disk if there is any Exception, If I do not get
any exception I will clear the buffer without writing anything.And to check
the exception, I have had the hook of check which tells when to dump and
when not.  And I configure this Appender with root logger so that it
captures as a summary log as well.

Any other approach I can have?

-Sudharma


On Fri, Oct 11, 2013 at 9:35 PM, Ralph Goers <ra...@dslextreme.com>wrote:

> I guess I need a better understanding of what you want.  It sounds like
> when your application has a failure you want to start logging more stuff.
>  Normally, you would do that by changing logging levels, not by introducing
> a new Appender.  FWIW, most people want to capture messages and then log
> what happened before the failure when the failure occurs.
>
> Ralph
>
> On Oct 10, 2013, at 11:40 PM, Sudharma Puranik <su...@gmail.com>
> wrote:
>
> Hi Ralph,
>
> for me its not on the fail of appender but fail of my application I have
> to log to disk? FailOver will only switch to secondary appender if first
> fails, but failure for me is in application not appender.
>
> Is my thinking wrong anywhere?
>
> -Sudharma
>
>
> On Fri, Oct 11, 2013 at 10:55 AM, Ralph Goers <rg...@apache.org> wrote:
>
>> Did you make sure to specify ignoreExceptions="false" on the appender to
>> be failed over?
>>
>> Ralph
>>
>> On Oct 10, 2013, at 10:21 PM, Sudharma Puranik <
>> sudharma.puranik@gmail.com> wrote:
>>
>> Failover Appender dint work for me.. I will send you the details soon...
>> hardly pressed with work.
>>
>> -Sudharma
>>
>>
>> On Thu, Oct 10, 2013 at 3:48 PM, Ralph Goers <rg...@apache.org> wrote:
>>
>>> The FailoverAppender didn't work for you? If not, why?
>>>
>>> To get your plugin to be found you either need to add its package to the
>>> packages attribute of the configuration element or you need to use "plugin
>>> preloading", which is documented on the Plugins page on the web site,
>>>
>>> Ralph
>>>
>>> On Oct 10, 2013, at 1:43 AM, Sudharma Puranik <
>>> sudharma.puranik@gmail.com> wrote:
>>>
>>> I created my custom Appender and Manager and added it into the plugins
>>> which work properly.  But I have a problem like  I have to always compile
>>> the core and deploy it back which is not a good idea.. Does the log4j2
>>> provide any dropin solution for plugins? Or is it that , do you have any
>>> other way of doing it?
>>>
>>> kindly help
>>>
>>> -Sudharma
>>>
>>>
>>> On Thu, Oct 10, 2013 at 12:13 AM, Ralph Goers <
>>> ralph.goers@dslextreme.com> wrote:
>>>
>>>> Try the FailoverAppender.  See
>>>> http://logging.apache.org/log4j/2.x/manual/appenders.html#FailoverAppender
>>>> .
>>>>
>>>> Ralph
>>>>
>>>> On Oct 9, 2013, at 10:25 AM, Sudharma Puranik <
>>>> sudharma.puranik@gmail.com> wrote:
>>>>
>>>> > Hello,
>>>> >
>>>> > I have a special case of logging, that is , whenever I get an Error I
>>>> would want to log to disk. Kind of a Dump log. The approach I have used so
>>>> far are,
>>>> >
>>>> > 1. extend RollingRandomAccessAppender and RandomAccessManager and
>>>> create my own write method which will only write to a IO Stream and when
>>>> error occurs I flush it using ByteBuffer. But the problem is I am not able
>>>> to get the hook of Exception handling.
>>>> >
>>>> > 2 Tried to write my own NIO streaming with different thread. But
>>>> handling rollover is not managable.
>>>> >
>>>> > Could you please suggest me a better approach for this?
>>>> >
>>>> > -Sudharma
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>>>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>>>>
>>>>
>>>
>>
>
>

Re: Logging to Disk in case of only Error

Posted by Ralph Goers <ra...@dslextreme.com>.
I guess I need a better understanding of what you want.  It sounds like when your application has a failure you want to start logging more stuff.  Normally, you would do that by changing logging levels, not by introducing a new Appender.  FWIW, most people want to capture messages and then log what happened before the failure when the failure occurs. 

Ralph

On Oct 10, 2013, at 11:40 PM, Sudharma Puranik <su...@gmail.com> wrote:

> Hi Ralph,
> 
> for me its not on the fail of appender but fail of my application I have to log to disk? FailOver will only switch to secondary appender if first fails, but failure for me is in application not appender. 
> 
> Is my thinking wrong anywhere?
> 
> -Sudharma
> 
> 
> On Fri, Oct 11, 2013 at 10:55 AM, Ralph Goers <rg...@apache.org> wrote:
> Did you make sure to specify ignoreExceptions="false" on the appender to be failed over?
> 
> Ralph
> 
> On Oct 10, 2013, at 10:21 PM, Sudharma Puranik <su...@gmail.com> wrote:
> 
>> Failover Appender dint work for me.. I will send you the details soon... hardly pressed with work.
>> 
>> -Sudharma
>> 
>> 
>> On Thu, Oct 10, 2013 at 3:48 PM, Ralph Goers <rg...@apache.org> wrote:
>> The FailoverAppender didn't work for you? If not, why?
>> 
>> To get your plugin to be found you either need to add its package to the packages attribute of the configuration element or you need to use "plugin preloading", which is documented on the Plugins page on the web site,
>> 
>> Ralph
>> 
>> On Oct 10, 2013, at 1:43 AM, Sudharma Puranik <su...@gmail.com> wrote:
>> 
>>> I created my custom Appender and Manager and added it into the plugins which work properly.  But I have a problem like  I have to always compile the core and deploy it back which is not a good idea.. Does the log4j2 provide any dropin solution for plugins? Or is it that , do you have any other way of doing it?
>>> 
>>> kindly help
>>> 
>>> -Sudharma
>>> 
>>> 
>>> On Thu, Oct 10, 2013 at 12:13 AM, Ralph Goers <ra...@dslextreme.com> wrote:
>>> Try the FailoverAppender.  See http://logging.apache.org/log4j/2.x/manual/appenders.html#FailoverAppender.
>>> 
>>> Ralph
>>> 
>>> On Oct 9, 2013, at 10:25 AM, Sudharma Puranik <su...@gmail.com> wrote:
>>> 
>>> > Hello,
>>> >
>>> > I have a special case of logging, that is , whenever I get an Error I would want to log to disk. Kind of a Dump log. The approach I have used so far are,
>>> >
>>> > 1. extend RollingRandomAccessAppender and RandomAccessManager and create my own write method which will only write to a IO Stream and when error occurs I flush it using ByteBuffer. But the problem is I am not able to get the hook of Exception handling.
>>> >
>>> > 2 Tried to write my own NIO streaming with different thread. But handling rollover is not managable.
>>> >
>>> > Could you please suggest me a better approach for this?
>>> >
>>> > -Sudharma
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>>> 
>>> 
>> 
> 


Re: Logging to Disk in case of only Error

Posted by Sudharma Puranik <su...@gmail.com>.
Hi Ralph,

for me its not on the fail of appender but fail of my application I have to
log to disk? FailOver will only switch to secondary appender if first
fails, but failure for me is in application not appender.

Is my thinking wrong anywhere?

-Sudharma


On Fri, Oct 11, 2013 at 10:55 AM, Ralph Goers <rg...@apache.org> wrote:

> Did you make sure to specify ignoreExceptions="false" on the appender to
> be failed over?
>
> Ralph
>
> On Oct 10, 2013, at 10:21 PM, Sudharma Puranik <su...@gmail.com>
> wrote:
>
> Failover Appender dint work for me.. I will send you the details soon...
> hardly pressed with work.
>
> -Sudharma
>
>
> On Thu, Oct 10, 2013 at 3:48 PM, Ralph Goers <rg...@apache.org> wrote:
>
>> The FailoverAppender didn't work for you? If not, why?
>>
>> To get your plugin to be found you either need to add its package to the
>> packages attribute of the configuration element or you need to use "plugin
>> preloading", which is documented on the Plugins page on the web site,
>>
>> Ralph
>>
>> On Oct 10, 2013, at 1:43 AM, Sudharma Puranik <su...@gmail.com>
>> wrote:
>>
>> I created my custom Appender and Manager and added it into the plugins
>> which work properly.  But I have a problem like  I have to always compile
>> the core and deploy it back which is not a good idea.. Does the log4j2
>> provide any dropin solution for plugins? Or is it that , do you have any
>> other way of doing it?
>>
>> kindly help
>>
>> -Sudharma
>>
>>
>> On Thu, Oct 10, 2013 at 12:13 AM, Ralph Goers <ralph.goers@dslextreme.com
>> > wrote:
>>
>>> Try the FailoverAppender.  See
>>> http://logging.apache.org/log4j/2.x/manual/appenders.html#FailoverAppender
>>> .
>>>
>>> Ralph
>>>
>>> On Oct 9, 2013, at 10:25 AM, Sudharma Puranik <
>>> sudharma.puranik@gmail.com> wrote:
>>>
>>> > Hello,
>>> >
>>> > I have a special case of logging, that is , whenever I get an Error I
>>> would want to log to disk. Kind of a Dump log. The approach I have used so
>>> far are,
>>> >
>>> > 1. extend RollingRandomAccessAppender and RandomAccessManager and
>>> create my own write method which will only write to a IO Stream and when
>>> error occurs I flush it using ByteBuffer. But the problem is I am not able
>>> to get the hook of Exception handling.
>>> >
>>> > 2 Tried to write my own NIO streaming with different thread. But
>>> handling rollover is not managable.
>>> >
>>> > Could you please suggest me a better approach for this?
>>> >
>>> > -Sudharma
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>>>
>>>
>>
>

Re: Logging to Disk in case of only Error

Posted by Ralph Goers <rg...@apache.org>.
Did you make sure to specify ignoreExceptions="false" on the appender to be failed over?

Ralph

> On Oct 10, 2013, at 10:21 PM, Sudharma Puranik <su...@gmail.com> wrote:
> 
> Failover Appender dint work for me.. I will send you the details soon... hardly pressed with work.
> 
> -Sudharma
> 
> 
>> On Thu, Oct 10, 2013 at 3:48 PM, Ralph Goers <rg...@apache.org> wrote:
>> The FailoverAppender didn't work for you? If not, why?
>> 
>> To get your plugin to be found you either need to add its package to the packages attribute of the configuration element or you need to use "plugin preloading", which is documented on the Plugins page on the web site,
>> 
>> Ralph
>> 
>>> On Oct 10, 2013, at 1:43 AM, Sudharma Puranik <su...@gmail.com> wrote:
>>> 
>>> I created my custom Appender and Manager and added it into the plugins which work properly.  But I have a problem like  I have to always compile the core and deploy it back which is not a good idea.. Does the log4j2 provide any dropin solution for plugins? Or is it that , do you have any other way of doing it?
>>> 
>>> kindly help
>>> 
>>> -Sudharma
>>> 
>>> 
>>>> On Thu, Oct 10, 2013 at 12:13 AM, Ralph Goers <ra...@dslextreme.com> wrote:
>>>> Try the FailoverAppender.  See http://logging.apache.org/log4j/2.x/manual/appenders.html#FailoverAppender.
>>>> 
>>>> Ralph
>>>> 
>>>> On Oct 9, 2013, at 10:25 AM, Sudharma Puranik <su...@gmail.com> wrote:
>>>> 
>>>> > Hello,
>>>> >
>>>> > I have a special case of logging, that is , whenever I get an Error I would want to log to disk. Kind of a Dump log. The approach I have used so far are,
>>>> >
>>>> > 1. extend RollingRandomAccessAppender and RandomAccessManager and create my own write method which will only write to a IO Stream and when error occurs I flush it using ByteBuffer. But the problem is I am not able to get the hook of Exception handling.
>>>> >
>>>> > 2 Tried to write my own NIO streaming with different thread. But handling rollover is not managable.
>>>> >
>>>> > Could you please suggest me a better approach for this?
>>>> >
>>>> > -Sudharma
>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>>>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
> 

Re: Logging to Disk in case of only Error

Posted by Sudharma Puranik <su...@gmail.com>.
Failover Appender dint work for me.. I will send you the details soon...
hardly pressed with work.

-Sudharma


On Thu, Oct 10, 2013 at 3:48 PM, Ralph Goers <rg...@apache.org> wrote:

> The FailoverAppender didn't work for you? If not, why?
>
> To get your plugin to be found you either need to add its package to the
> packages attribute of the configuration element or you need to use "plugin
> preloading", which is documented on the Plugins page on the web site,
>
> Ralph
>
> On Oct 10, 2013, at 1:43 AM, Sudharma Puranik <su...@gmail.com>
> wrote:
>
> I created my custom Appender and Manager and added it into the plugins
> which work properly.  But I have a problem like  I have to always compile
> the core and deploy it back which is not a good idea.. Does the log4j2
> provide any dropin solution for plugins? Or is it that , do you have any
> other way of doing it?
>
> kindly help
>
> -Sudharma
>
>
> On Thu, Oct 10, 2013 at 12:13 AM, Ralph Goers <ra...@dslextreme.com>wrote:
>
>> Try the FailoverAppender.  See
>> http://logging.apache.org/log4j/2.x/manual/appenders.html#FailoverAppender
>> .
>>
>> Ralph
>>
>> On Oct 9, 2013, at 10:25 AM, Sudharma Puranik <su...@gmail.com>
>> wrote:
>>
>> > Hello,
>> >
>> > I have a special case of logging, that is , whenever I get an Error I
>> would want to log to disk. Kind of a Dump log. The approach I have used so
>> far are,
>> >
>> > 1. extend RollingRandomAccessAppender and RandomAccessManager and
>> create my own write method which will only write to a IO Stream and when
>> error occurs I flush it using ByteBuffer. But the problem is I am not able
>> to get the hook of Exception handling.
>> >
>> > 2 Tried to write my own NIO streaming with different thread. But
>> handling rollover is not managable.
>> >
>> > Could you please suggest me a better approach for this?
>> >
>> > -Sudharma
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>>
>>
>

Re: Logging to Disk in case of only Error

Posted by Ralph Goers <rg...@apache.org>.
The FailoverAppender didn't work for you? If not, why?

To get your plugin to be found you either need to add its package to the packages attribute of the configuration element or you need to use "plugin preloading", which is documented on the Plugins page on the web site,

Ralph

> On Oct 10, 2013, at 1:43 AM, Sudharma Puranik <su...@gmail.com> wrote:
> 
> I created my custom Appender and Manager and added it into the plugins which work properly.  But I have a problem like  I have to always compile the core and deploy it back which is not a good idea.. Does the log4j2 provide any dropin solution for plugins? Or is it that , do you have any other way of doing it?
> 
> kindly help
> 
> -Sudharma
> 
> 
>> On Thu, Oct 10, 2013 at 12:13 AM, Ralph Goers <ra...@dslextreme.com> wrote:
>> Try the FailoverAppender.  See http://logging.apache.org/log4j/2.x/manual/appenders.html#FailoverAppender.
>> 
>> Ralph
>> 
>> On Oct 9, 2013, at 10:25 AM, Sudharma Puranik <su...@gmail.com> wrote:
>> 
>> > Hello,
>> >
>> > I have a special case of logging, that is , whenever I get an Error I would want to log to disk. Kind of a Dump log. The approach I have used so far are,
>> >
>> > 1. extend RollingRandomAccessAppender and RandomAccessManager and create my own write method which will only write to a IO Stream and when error occurs I flush it using ByteBuffer. But the problem is I am not able to get the hook of Exception handling.
>> >
>> > 2 Tried to write my own NIO streaming with different thread. But handling rollover is not managable.
>> >
>> > Could you please suggest me a better approach for this?
>> >
>> > -Sudharma
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
> 

Re: Logging to Disk in case of only Error

Posted by Sudharma Puranik <su...@gmail.com>.
I created my custom Appender and Manager and added it into the plugins
which work properly.  But I have a problem like  I have to always compile
the core and deploy it back which is not a good idea.. Does the log4j2
provide any dropin solution for plugins? Or is it that , do you have any
other way of doing it?

kindly help

-Sudharma


On Thu, Oct 10, 2013 at 12:13 AM, Ralph Goers <ra...@dslextreme.com>wrote:

> Try the FailoverAppender.  See
> http://logging.apache.org/log4j/2.x/manual/appenders.html#FailoverAppender
> .
>
> Ralph
>
> On Oct 9, 2013, at 10:25 AM, Sudharma Puranik <su...@gmail.com>
> wrote:
>
> > Hello,
> >
> > I have a special case of logging, that is , whenever I get an Error I
> would want to log to disk. Kind of a Dump log. The approach I have used so
> far are,
> >
> > 1. extend RollingRandomAccessAppender and RandomAccessManager and create
> my own write method which will only write to a IO Stream and when error
> occurs I flush it using ByteBuffer. But the problem is I am not able to get
> the hook of Exception handling.
> >
> > 2 Tried to write my own NIO streaming with different thread. But
> handling rollover is not managable.
> >
> > Could you please suggest me a better approach for this?
> >
> > -Sudharma
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
>

Re: Logging to Disk in case of only Error

Posted by Ralph Goers <ra...@dslextreme.com>.
Try the FailoverAppender.  See http://logging.apache.org/log4j/2.x/manual/appenders.html#FailoverAppender.

Ralph

On Oct 9, 2013, at 10:25 AM, Sudharma Puranik <su...@gmail.com> wrote:

> Hello,
> 
> I have a special case of logging, that is , whenever I get an Error I would want to log to disk. Kind of a Dump log. The approach I have used so far are,
> 
> 1. extend RollingRandomAccessAppender and RandomAccessManager and create my own write method which will only write to a IO Stream and when error occurs I flush it using ByteBuffer. But the problem is I am not able to get the hook of Exception handling.
> 
> 2 Tried to write my own NIO streaming with different thread. But handling rollover is not managable.
> 
> Could you please suggest me a better approach for this?
> 
> -Sudharma


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