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 Stroboskop <gn...@web.de> on 2007/06/11 18:51:52 UTC
How to handle log4j's internal exceptions
OK, here's my problem:
i want to know when _log4j_ is having a problem.
For example: imagine using a FileAppender pointing to a directory on the
network - sometimes you don't have write access rights and sometimes the
directory's just not available. Anyway your chances are good that regular
logging wont work at all.
So i want to be notified, when log4j catches an exception.
Since log4j's internal problems are logged using LogLog, i might need to
somehow implement/overload the internal logging. How do do that?
Originally i thought, i'd just need to register an exception handler with
log4j, but there doesn't seem to be such a thing. Or at least i didn't find
it.
I know only the most basic things about log4j, so maybe it's easy. But i
looked at the wiki, faq's and the API and did't find anything that helped...
--
View this message in context: http://www.nabble.com/How-to-handle-log4j%27s-internal-exceptions-tf3902661.html#a11064210
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: How to handle log4j's internal exceptions
Posted by Ceki Gulcu <li...@qos.ch>.
Hello,
Internal error handling is one of the strong points of logback, the purported
successor to log4j. Each logback component is attached to a context which
maintains a publicly accessible list of internal errors. Search for
StatusManager in logback documentation.
See also "Chapter 2 - Architecture" in the logback manual for further details:
http://logback.qos.ch/manual/architecture.html
I hope this helps,
Stroboskop wrote:
> OK, here's my problem:
> i want to know when _log4j_ is having a problem.
>
> For example: imagine using a FileAppender pointing to a directory on the
> network - sometimes you don't have write access rights and sometimes the
> directory's just not available. Anyway your chances are good that regular
> logging wont work at all.
> So i want to be notified, when log4j catches an exception.
>
> Since log4j's internal problems are logged using LogLog, i might need to
> somehow implement/overload the internal logging. How do do that?
>
> Originally i thought, i'd just need to register an exception handler with
> log4j, but there doesn't seem to be such a thing. Or at least i didn't find
> it.
>
> I know only the most basic things about log4j, so maybe it's easy. But i
> looked at the wiki, faq's and the API and did't find anything that helped...
>
--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
RE: How to handle log4j's internal exceptions
Posted by Stroboskop <gn...@web.de>.
log4j.properties configuration of ErrorHandlers just doesn't work.
But thanks for your help.
I'm using setErrorHandler at application start up. So i can't catch problems
during config parsing, but at least i'm notified when a broken logger is
used afterwards.
Kamal Ahmed-3 wrote:
>
> Did you try something like:
>
> log4j.appender.systemOut.errorHandler =
> org.apache.log4j.varia.FallbackErrorHandler
>
> to see if this works
>
> -----Original Message-----
> From: Stroboskop [mailto:gnubeutel@web.de]
> Sent: Tuesday, June 12, 2007 1:55 PM
> To: log4j-user@logging.apache.org
> Subject: RE: How to handle log4j's internal exceptions
>
>
> I don't think, that's what i wanted to know.
> I didn't want to set the log level to ERROR, i wanted to set an
> ErrorHandler.
>
> So i was more thinking along the line of:
>
> log4j.appender.File.errorHandler=com.my.very.own.ErrorHandler
>
> When i set it programatically, it works fine. This of course doesn't.
>
>
>
>
> Kamal Ahmed-3 wrote:
>>
>> As for #1, in log4j.properties
>>
>> Example:
>>
>> log4j.logger.com.handler.DefaultMessageHandler=ERROR
>>
>>
>> for # 2: Ask Ceki Gülcü
>>
>>
>>
>>
>> -----Original Message-----
>> From: Stroboskop [mailto:gnubeutel@web.de]
>> Sent: Tuesday, June 12, 2007 9:36 AM
>> To: log4j-user@logging.apache.org
>> Subject: RE: How to handle log4j's internal exceptions
>>
>>
>> ErrorHandler! That's it! Thanks a lot.
>>
>> But two more questions arise:
>> - how do i set the error handler using the log4j.properties config? I
>> only
>> found xml config examples.
>> - why is the ErrorHandler deprecated in log4j 1.3 (and with no
>> substitute
>> mechanism at that)?
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-handle-log4j%27s-internal-exceptions-tf3902661.html#a11078880
>> Sent from the Log4j - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/How-to-handle-log4j%27s-internal-exceptions-tf3902661.html#a11083714
> Sent from the Log4j - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/How-to-handle-log4j%27s-internal-exceptions-tf3902661.html#a11098178
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
RE: How to handle log4j's internal exceptions
Posted by Kamal Ahmed <KA...@webMethods.com>.
Did you try something like:
log4j.appender.systemOut.errorHandler = org.apache.log4j.varia.FallbackErrorHandler
to see if this works
-----Original Message-----
From: Stroboskop [mailto:gnubeutel@web.de]
Sent: Tuesday, June 12, 2007 1:55 PM
To: log4j-user@logging.apache.org
Subject: RE: How to handle log4j's internal exceptions
I don't think, that's what i wanted to know.
I didn't want to set the log level to ERROR, i wanted to set an
ErrorHandler.
So i was more thinking along the line of:
log4j.appender.File.errorHandler=com.my.very.own.ErrorHandler
When i set it programatically, it works fine. This of course doesn't.
Kamal Ahmed-3 wrote:
>
> As for #1, in log4j.properties
>
> Example:
>
> log4j.logger.com.handler.DefaultMessageHandler=ERROR
>
>
> for # 2: Ask Ceki Gülcü
>
>
>
>
> -----Original Message-----
> From: Stroboskop [mailto:gnubeutel@web.de]
> Sent: Tuesday, June 12, 2007 9:36 AM
> To: log4j-user@logging.apache.org
> Subject: RE: How to handle log4j's internal exceptions
>
>
> ErrorHandler! That's it! Thanks a lot.
>
> But two more questions arise:
> - how do i set the error handler using the log4j.properties config? I
> only
> found xml config examples.
> - why is the ErrorHandler deprecated in log4j 1.3 (and with no substitute
> mechanism at that)?
>
> --
> View this message in context:
> http://www.nabble.com/How-to-handle-log4j%27s-internal-exceptions-tf3902661.html#a11078880
> Sent from the Log4j - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/How-to-handle-log4j%27s-internal-exceptions-tf3902661.html#a11083714
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
RE: How to handle log4j's internal exceptions
Posted by Stroboskop <gn...@web.de>.
I don't think, that's what i wanted to know.
I didn't want to set the log level to ERROR, i wanted to set an
ErrorHandler.
So i was more thinking along the line of:
log4j.appender.File.errorHandler=com.my.very.own.ErrorHandler
When i set it programatically, it works fine. This of course doesn't.
Kamal Ahmed-3 wrote:
>
> As for #1, in log4j.properties
>
> Example:
>
> log4j.logger.com.handler.DefaultMessageHandler=ERROR
>
>
> for # 2: Ask Ceki Gülcü
>
>
>
>
> -----Original Message-----
> From: Stroboskop [mailto:gnubeutel@web.de]
> Sent: Tuesday, June 12, 2007 9:36 AM
> To: log4j-user@logging.apache.org
> Subject: RE: How to handle log4j's internal exceptions
>
>
> ErrorHandler! That's it! Thanks a lot.
>
> But two more questions arise:
> - how do i set the error handler using the log4j.properties config? I
> only
> found xml config examples.
> - why is the ErrorHandler deprecated in log4j 1.3 (and with no substitute
> mechanism at that)?
>
> --
> View this message in context:
> http://www.nabble.com/How-to-handle-log4j%27s-internal-exceptions-tf3902661.html#a11078880
> Sent from the Log4j - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/How-to-handle-log4j%27s-internal-exceptions-tf3902661.html#a11083714
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
RE: How to handle log4j's internal exceptions
Posted by Kamal Ahmed <KA...@webMethods.com>.
As for #1, in log4j.properties
Example:
log4j.logger.com.handler.DefaultMessageHandler=ERROR
for # 2: Ask Ceki Gülcü
-----Original Message-----
From: Stroboskop [mailto:gnubeutel@web.de]
Sent: Tuesday, June 12, 2007 9:36 AM
To: log4j-user@logging.apache.org
Subject: RE: How to handle log4j's internal exceptions
ErrorHandler! That's it! Thanks a lot.
But two more questions arise:
- how do i set the error handler using the log4j.properties config? I only
found xml config examples.
- why is the ErrorHandler deprecated in log4j 1.3 (and with no substitute
mechanism at that)?
--
View this message in context: http://www.nabble.com/How-to-handle-log4j%27s-internal-exceptions-tf3902661.html#a11078880
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
RE: How to handle log4j's internal exceptions
Posted by Stroboskop <gn...@web.de>.
ErrorHandler! That's it! Thanks a lot.
But two more questions arise:
- how do i set the error handler using the log4j.properties config? I only
found xml config examples.
- why is the ErrorHandler deprecated in log4j 1.3 (and with no substitute
mechanism at that)?
--
View this message in context: http://www.nabble.com/How-to-handle-log4j%27s-internal-exceptions-tf3902661.html#a11078880
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
RE: How to handle log4j's internal exceptions
Posted by Kamal Ahmed <KA...@webMethods.com>.
Stroboskop,
The following is an example of how we can have customized Errors for
LogLog Messages
<appender instance>.getErrorHandler().error(
"Custom Message ........ ErrorHandler
Handles the Event");
Hope this helps
-Kamal.
-----Original Message-----
From: Stroboskop [mailto:gnubeutel@web.de]
Sent: Monday, June 11, 2007 12:52 PM
To: log4j-user@logging.apache.org
Subject: How to handle log4j's internal exceptions
OK, here's my problem:
i want to know when _log4j_ is having a problem.
For example: imagine using a FileAppender pointing to a directory on the
network - sometimes you don't have write access rights and sometimes the
directory's just not available. Anyway your chances are good that
regular
logging wont work at all.
So i want to be notified, when log4j catches an exception.
Since log4j's internal problems are logged using LogLog, i might need to
somehow implement/overload the internal logging. How do do that?
Originally i thought, i'd just need to register an exception handler
with
log4j, but there doesn't seem to be such a thing. Or at least i didn't
find
it.
I know only the most basic things about log4j, so maybe it's easy. But i
looked at the wiki, faq's and the API and did't find anything that
helped...
--
View this message in context:
http://www.nabble.com/How-to-handle-log4j%27s-internal-exceptions-tf3902
661.html#a11064210
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org