logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maple Wang <maple.feng.w...@hotmail.com>
Subject RE: how to ensure my hook is invoked before shutdown hook of log4j
Date Fri, 24 Jun 2016 14:44:59 GMT
Hi,

It works for me with properties file, thanks guys.

Best regards.

-----Original Message-----
From: Matt Sicker [mailto:boards@gmail.com] 
Sent: Friday, June 24, 2016 10:40 PM
To: Log4J Users List
Subject: Re: how to ensure my hook is invoked before shutdown hook of log4j

You can also specify the JVM parameters through a file called log4j2.component.properties

On 24 June 2016 at 07:48, Ralph Goers <ralph.goers@dslextreme.com> wrote:

> If you have code that runs at startup and shutdown then you should 
> programmatically start and stop Log4j from there and turn off Log4j’s 
> automatic handling of it.  You would call Configurator.initialize at 
> startup and Configurator.shutdown from your shutdown hook.
>
> Ralph
>
> > On Jun 24, 2016, at 3:25 AM, Maple Wang 
> > <maple.feng.wang@hotmail.com>
> wrote:
> >
> > Hi,
> >
> > I registered a shutdownhook in my code and found that there is no 
> > any
> log output from my hook method, the reason is that since log4j2.1, 
> shutdown hook registry will be enabled by default from log4j, logger 
> is stopped by log4j's hook before my hook is invoked.
> >
> > Of course I can disable the hook from log4j by
> "-Dlog4j.shutdownHookEnabled=false", but I think it might be better to 
> keep it, so I wonder if there is way to ensure my hook is invoked 
> before log4j's hook.
> >
> > And if there is no that way, is there any programmatic way to 
> > disable
> the log4j's shutdownhook rather than JVM parameter.
> >
> > Thanks in advance.
> >
> > Best regards.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


--
Matt Sicker <boards@gmail.com>
Mime
View raw message