Invoke custom code after RollingFileAppender append()

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Invoke custom code after RollingFileAppender append()

gaurav9822@gmail.com
Hi log4jusers,

Want to invoke custom code(to send email) after the RollingFileAppender
append event.

What would you suggest?

P.S. Cannot extend RollingFileAppender, as it is final.

Please help

Thank you,
Gaurav
Reply | Threaded
Open this post in threaded view
|

Re: Invoke custom code after RollingFileAppender append()

Gary Gregory-4
Maybe we should introduce the ability to inject a custom class pre and post
even processing? We could provide an implementation based on the scripting
API so folks could just write JavaScript directly in the config.

Gary

On Fri, Feb 15, 2019 at 7:34 AM gaurav <[hidden email]> wrote:

> Hi log4jusers,
>
> Want to invoke custom code(to send email) after the RollingFileAppender
> append event.
>
> What would you suggest?
>
> P.S. Cannot extend RollingFileAppender, as it is final.
>
> Please help
>
> Thank you,
> Gaurav
>
Reply | Threaded
Open this post in threaded view
|

Re: Invoke custom code after RollingFileAppender append()

Ralph Goers
I don’t think I understand this requirement. Why couldn’t they just create a filter that sends the email. Sure, it won’t be right after the event is logged but so what?

Ralph

> On Feb 15, 2019, at 7:15 AM, Gary Gregory <[hidden email]> wrote:
>
> Maybe we should introduce the ability to inject a custom class pre and post
> even processing? We could provide an implementation based on the scripting
> API so folks could just write JavaScript directly in the config.
>
> Gary
>
> On Fri, Feb 15, 2019 at 7:34 AM gaurav <[hidden email]> wrote:
>
>> Hi log4jusers,
>>
>> Want to invoke custom code(to send email) after the RollingFileAppender
>> append event.
>>
>> What would you suggest?
>>
>> P.S. Cannot extend RollingFileAppender, as it is final.
>>
>> Please help
>>
>> Thank you,
>> Gaurav
>>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Invoke custom code after RollingFileAppender append()

Remko Popma-2
Ralph,

I guess then the question becomes: how can the filter detect that a particular event triggered a rollover?

Remko.

(Shameless plug) Every java main() method deserves http://picocli.info

> On Feb 15, 2019, at 23:39, Ralph Goers <[hidden email]> wrote:
>
> I don’t think I understand this requirement. Why couldn’t they just create a filter that sends the email. Sure, it won’t be right after the event is logged but so what?
>
> Ralph
>
>> On Feb 15, 2019, at 7:15 AM, Gary Gregory <[hidden email]> wrote:
>>
>> Maybe we should introduce the ability to inject a custom class pre and post
>> even processing? We could provide an implementation based on the scripting
>> API so folks could just write JavaScript directly in the config.
>>
>> Gary
>>
>>> On Fri, Feb 15, 2019 at 7:34 AM gaurav <[hidden email]> wrote:
>>>
>>> Hi log4jusers,
>>>
>>> Want to invoke custom code(to send email) after the RollingFileAppender
>>> append event.
>>>
>>> What would you suggest?
>>>
>>> P.S. Cannot extend RollingFileAppender, as it is final.
>>>
>>> Please help
>>>
>>> Thank you,
>>> Gaurav
>>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Invoke custom code after RollingFileAppender append()

Remko Popma-2
At least, I think the intention is to send email on rollover, based on this SO comment https://stackoverflow.com/questions/39137396/how-to-extend-log4j2-rollingfileappender/39141257#comment96203788_39141257

(Shameless plug) Every java main() method deserves http://picocli.info

> On Feb 16, 2019, at 0:54, Remko Popma <[hidden email]> wrote:
>
> Ralph,
>
> I guess then the question becomes: how can the filter detect that a particular event triggered a rollover?
>
> Remko.
>
> (Shameless plug) Every java main() method deserves http://picocli.info
>
>> On Feb 15, 2019, at 23:39, Ralph Goers <[hidden email]> wrote:
>>
>> I don’t think I understand this requirement. Why couldn’t they just create a filter that sends the email. Sure, it won’t be right after the event is logged but so what?
>>
>> Ralph
>>
>>> On Feb 15, 2019, at 7:15 AM, Gary Gregory <[hidden email]> wrote:
>>>
>>> Maybe we should introduce the ability to inject a custom class pre and post
>>> even processing? We could provide an implementation based on the scripting
>>> API so folks could just write JavaScript directly in the config.
>>>
>>> Gary
>>>
>>>> On Fri, Feb 15, 2019 at 7:34 AM gaurav <[hidden email]> wrote:
>>>>
>>>> Hi log4jusers,
>>>>
>>>> Want to invoke custom code(to send email) after the RollingFileAppender
>>>> append event.
>>>>
>>>> What would you suggest?
>>>>
>>>> P.S. Cannot extend RollingFileAppender, as it is final.
>>>>
>>>> Please help
>>>>
>>>> Thank you,
>>>> Gaurav
>>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
Reply | Threaded
Open this post in threaded view
|

Re: Invoke custom code after RollingFileAppender append()

Ralph Goers
In reply to this post by Remko Popma-2
That isn’t what was asked for.  He asked to send an email after the appender appends an event.

Ralph

> On Feb 15, 2019, at 8:54 AM, Remko Popma <[hidden email]> wrote:
>
> Ralph,
>
> I guess then the question becomes: how can the filter detect that a particular event triggered a rollover?
>
> Remko.
>
> (Shameless plug) Every java main() method deserves http://picocli.info
>
>> On Feb 15, 2019, at 23:39, Ralph Goers <[hidden email]> wrote:
>>
>> I don’t think I understand this requirement. Why couldn’t they just create a filter that sends the email. Sure, it won’t be right after the event is logged but so what?
>>
>> Ralph
>>
>>> On Feb 15, 2019, at 7:15 AM, Gary Gregory <[hidden email]> wrote:
>>>
>>> Maybe we should introduce the ability to inject a custom class pre and post
>>> even processing? We could provide an implementation based on the scripting
>>> API so folks could just write JavaScript directly in the config.
>>>
>>> Gary
>>>
>>>> On Fri, Feb 15, 2019 at 7:34 AM gaurav <[hidden email]> wrote:
>>>>
>>>> Hi log4jusers,
>>>>
>>>> Want to invoke custom code(to send email) after the RollingFileAppender
>>>> append event.
>>>>
>>>> What would you suggest?
>>>>
>>>> P.S. Cannot extend RollingFileAppender, as it is final.
>>>>
>>>> Please help
>>>>
>>>> Thank you,
>>>> Gaurav
>>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Invoke custom code after RollingFileAppender append()

Ralph Goers
In reply to this post by Remko Popma-2
OK, but in that case using an Action is the correct approach as you responded. It will get control just after the gzip file is created. If you want to support scripting then we could create a ScriptAction.

Ralph

> On Feb 15, 2019, at 8:57 AM, Remko Popma <[hidden email]> wrote:
>
> At least, I think the intention is to send email on rollover, based on this SO comment https://stackoverflow.com/questions/39137396/how-to-extend-log4j2-rollingfileappender/39141257#comment96203788_39141257
>
> (Shameless plug) Every java main() method deserves http://picocli.info
>
>> On Feb 16, 2019, at 0:54, Remko Popma <[hidden email]> wrote:
>>
>> Ralph,
>>
>> I guess then the question becomes: how can the filter detect that a particular event triggered a rollover?
>>
>> Remko.
>>
>> (Shameless plug) Every java main() method deserves http://picocli.info
>>
>>> On Feb 15, 2019, at 23:39, Ralph Goers <[hidden email]> wrote:
>>>
>>> I don’t think I understand this requirement. Why couldn’t they just create a filter that sends the email. Sure, it won’t be right after the event is logged but so what?
>>>
>>> Ralph
>>>
>>>> On Feb 15, 2019, at 7:15 AM, Gary Gregory <[hidden email]> wrote:
>>>>
>>>> Maybe we should introduce the ability to inject a custom class pre and post
>>>> even processing? We could provide an implementation based on the scripting
>>>> API so folks could just write JavaScript directly in the config.
>>>>
>>>> Gary
>>>>
>>>>> On Fri, Feb 15, 2019 at 7:34 AM gaurav <[hidden email]> wrote:
>>>>>
>>>>> Hi log4jusers,
>>>>>
>>>>> Want to invoke custom code(to send email) after the RollingFileAppender
>>>>> append event.
>>>>>
>>>>> What would you suggest?
>>>>>
>>>>> P.S. Cannot extend RollingFileAppender, as it is final.
>>>>>
>>>>> Please help
>>>>>
>>>>> Thank you,
>>>>> Gaurav
>>>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Invoke custom code after RollingFileAppender append()

gaurav9822@gmail.com
In reply to this post by Ralph Goers


On 2019/02/15 15:58:07, Ralph Goers <[hidden email]> wrote:

> That isn’t what was asked for.  He asked to send an email after the appender appends an event.
>
> Ralph
>
> > On Feb 15, 2019, at 8:54 AM, Remko Popma <[hidden email]> wrote:
> >
> > Ralph,
> >
> > I guess then the question becomes: how can the filter detect that a particular event triggered a rollover?
> >
> > Remko.
> >
> > (Shameless plug) Every java main() method deserves http://picocli.info
> >
> >> On Feb 15, 2019, at 23:39, Ralph Goers <[hidden email]> wrote:
> >>
> >> I don’t think I understand this requirement. Why couldn’t they just create a filter that sends the email. Sure, it won’t be right after the event is logged but so what?
> >>
> >> Ralph
> >>
> >>> On Feb 15, 2019, at 7:15 AM, Gary Gregory <[hidden email]> wrote:
> >>>
> >>> Maybe we should introduce the ability to inject a custom class pre and post
> >>> even processing? We could provide an implementation based on the scripting
> >>> API so folks could just write JavaScript directly in the config.
> >>>
> >>> Gary
> >>>
> >>>> On Fri, Feb 15, 2019 at 7:34 AM gaurav <[hidden email]> wrote:
> >>>>
> >>>> Hi log4jusers,
> >>>>
> >>>> Want to invoke custom code(to send email) after the RollingFileAppender
> >>>> append event.
> >>>>
> >>>> What would you suggest?
> >>>>
> >>>> P.S. Cannot extend RollingFileAppender, as it is final.
> >>>>
> >>>> Please help
> >>>>
> >>>> Thank you,
> >>>> Gaurav
> >>>>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
> Hi Ralph,
Correct. I want the Appender to append an event and then send an email with my custom code.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Invoke custom code after RollingFileAppender append()

gaurav9822@gmail.com
In reply to this post by Ralph Goers


On 2019/02/15 15:58:07, Ralph Goers <[hidden email]> wrote:

> That isn’t what was asked for.  He asked to send an email after the appender appends an event.
>
> Ralph
>
> > On Feb 15, 2019, at 8:54 AM, Remko Popma <[hidden email]> wrote:
> >
> > Ralph,
> >
> > I guess then the question becomes: how can the filter detect that a particular event triggered a rollover?
> >
> > Remko.
> >
> > (Shameless plug) Every java main() method deserves http://picocli.info
> >
> >> On Feb 15, 2019, at 23:39, Ralph Goers <[hidden email]> wrote:
> >>
> >> I don’t think I understand this requirement. Why couldn’t they just create a filter that sends the email. Sure, it won’t be right after the event is logged but so what?
> >>
> >> Ralph
> >>
> >>> On Feb 15, 2019, at 7:15 AM, Gary Gregory <[hidden email]> wrote:
> >>>
> >>> Maybe we should introduce the ability to inject a custom class pre and post
> >>> even processing? We could provide an implementation based on the scripting
> >>> API so folks could just write JavaScript directly in the config.
> >>>
> >>> Gary
> >>>
> >>>> On Fri, Feb 15, 2019 at 7:34 AM gaurav <[hidden email]> wrote:
> >>>>
> >>>> Hi log4jusers,
> >>>>
> >>>> Want to invoke custom code(to send email) after the RollingFileAppender
> >>>> append event.
> >>>>
> >>>> What would you suggest?
> >>>>
> >>>> P.S. Cannot extend RollingFileAppender, as it is final.
> >>>>
> >>>> Please help
> >>>>
> >>>> Thank you,
> >>>> Gaurav
> >>>>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
> Hi Ralph,
Correct. I want the Appender to append an event and then send an email with my custom code.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]