[undertow-dev] Undertow jboss logging redirect to logback log file and console

Bill O'Neil bill at dartalley.com
Wed Feb 8 06:22:51 EST 2017


2. As long as you are ok with making every route a blocking route that
should be fine. I did the same thing.

https://github.com/undertow-io/undertow/blob/master/core/src/main/java/io/undertow/server/handlers/BlockingHandler.java#L52

I use the blocking handler above before passing to the exception handler.
Your return seems out of place and it also never calls startBlocking(). I'm
not sure how important that is.

On Wed, Feb 8, 2017 at 5:53 AM, Steve Hu <stevehu at gmail.com> wrote:

> Just summarize what I have done and I think this is working for me very
> well.
>
> 1. I have put a line in my server during server start up to redirect
> Undertow logs to slf4j. -D in command line works but I think it impact the
> DevOps flow.
>
> System.setProperty("org.jboss.logging.provider", "slf4j");
>
> 2. I have put the following lines to dispatch in the beginning of ExceptionHandler.handleRequest. I think this is fine as most handlers shouldn't be executed in IO thread anyway. This will make sure that all exceptions will be captured by my handler instead of Connectors.
>
> if (exchange.isInIoThread()) {
>     exchange.dispatch(this);
>     return;
> }
>
> Thanks everyone for your help.
>
> Steve
>
>
>
> On Tue, Feb 7, 2017 at 9:48 PM, Steve Hu <stevehu at gmail.com> wrote:
>
>> Hi Kim/Miere,
>>
>> As a temp solution, I have tried both approaches and I can confirm that
>> the system property works. Somehow, I cannot make the SPI work. I even
>> tried to include jboss-logging, jboss-logging-processor and
>> jboss-logmanager.
>>
>> Thanks,
>>
>> Steve
>>
>> On Tue, Feb 7, 2017 at 1:48 PM, Kim Rasmussen <kr at asseco.dk> wrote:
>>
>>> Hi,
>>>
>>> I have had success with adding the system property:
>>>
>>> -Dorg.jboss.logging.provider=slf4j
>>>
>>> A random search for this on the net revelated this page which does a
>>> good job of explaining various ways of getting it working with WildFly - I
>>> myself use Undertow embedded, so the system property is enough for me.
>>>
>>> /Kim
>>>
>>> 2017-02-07 11:55 GMT+01:00 Miere Teixeira <miere.teixeira at gmail.com>:
>>>
>>>> Hi Steve,
>>>>
>>>> I've found myself on the same situation couple of years ago and to
>>>> solve my problem I've configured the LoggerProvider to point to
>>>> Slf4JLoggerProvider. Basically, this can be reproduced by declaring a
>>>> META-INF/services/org.jboss.logging.LoggerProvider file with
>>>> org.jboss.logging.Slf4jLoggerProvider as a value.
>>>>
>>>> I hope it helps.
>>>>
>>>> Cheers!
>>>>
>>>>
>>>> On Mon, Feb 6, 2017 at 9:09 PM Steve Hu <stevehu at gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> Undertow is using jboss logger to log errors and my application is
>>>>> using slf4j/logback with logback.xml config file in the classpath with
>>>>> Undertow core http server embedded. I handles most exceptions in my own
>>>>> handlers but sometimes uncaught exceptions reaches Connectors class - executeRootHandler
>>>>> method which logs the error and return 500 response code.
>>>>>
>>>>> My first question: Is there a way to redirect the logs from Undertow
>>>>> to logback logs and controlled by logback.xml? I've found some discussions
>>>>> about replacing logger in WildFly but I am using embedded Undertow core
>>>>> only.
>>>>>
>>>>> Second question: When Connectors.executeRootHandler will be called? Is
>>>>> it called when you have the following line in your handler?
>>>>>
>>>>> if (exchange.isInIoThread()) {
>>>>>      exchange.dispatch(this);
>>>>>      return;
>>>>>
>>>>> }
>>>>>
>>>>> Is there any way we can by pass this so that I can handle uncaught
>>>>> exceptions in my ExceptionHandler in the handler chain?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Steve
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> undertow-dev mailing list
>>>>> undertow-dev at lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/undertow-dev
>>>>
>>>> --
>>>>
>>>> Miere Teixeira
>>>>
>>>> _______________________________________________
>>>> undertow-dev mailing list
>>>> undertow-dev at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/undertow-dev
>>>>
>>>
>>>
>>>
>>> --
>>> Med venlig hilsen / Best regards
>>>
>>> *Kim Rasmussen*
>>> Partner, IT Architect
>>>
>>> *Asseco Denmark A/S*
>>> Kronprinsessegade 54
>>> DK-1306 Copenhagen K
>>> Mobile: +45 26 16 40 23 <+45%2026%2016%2040%2023>
>>> Ph.: +45 33 36 46 60 <+45%2033%2036%2046%2060>
>>> Fax: +45 33 36 46 61 <+45%2033%2036%2046%2061>
>>>
>>
>>
>
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20170208/e35042c3/attachment.html 


More information about the undertow-dev mailing list