So I am using the failoverappender with as primary a HTTP appender. The FailoverAppender docs state:
The FailoverAppender will capture exceptions in an Appender and then route the event to a different appender.
I could not find any documentation however when the HTTPappender will actually throw an exception. So what I was wondering is if my HTTP post request returns a 4XX or 5XX code will this actually throw a log4j exception and activate the failover?
Yes, if a 4xx
or 5xx
status code is returned, the failover appender will be used.
Which exceptions are thrown by HttpAppender
depend upon the implementation of HttpManager
in use. Right now the HttpURLConnectionManager
is hardcoded into Log4j, which relies upon your system's implementation of HttpURLConnection
implementation.
A 4xx
or 5xx
status code is one of the reasons the standard HttpURLConnection
in OpenJDK throws an exception (cf. source code).