Fwd: Re: How to build the Routing Appender with the ConfigurationBuilder

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

Fwd: Re: How to build the Routing Appender with the ConfigurationBuilder

Jens Schmidt
Hello Ralph,

thank you for your answer. That worked for the most part!
However using the CompnentBuilder i am not able to create an
OutputStreamAppender.

I looked into the Code and the internal Builder Classes of the
OutputStreamAppender and the WriterAppender are defined differently
compared to, e.g. the ConsoleAppender. I believe this to be a bug?.

Cheers Jens



Am 27.11.2017 um 18:36 schrieb Ralph Goers:

> What you need to know is that with the ConfigurationBuilder everything is really a Component. Since Layouts, Appenders, Filters and Loggers are so common we have built specialized ComponentBuilders for them, but they could also be constructed with a generic ComponentBuilder. https://logging.apache.org/log4j/2.x/manual/customconfig.html <https://logging.apache.org/log4j/2.x/manual/customconfig.html> provides some examples that show creating triggering policies using the generic ComponentBuilder. You can use that as a guide to help you figure out how to construct your routes.
>
> Ralph
>
>> On Nov 27, 2017, at 9:29 AM, Jens Schmidt <[hidden email]> wrote:
>>
>>
>> Hello there,
>>
>> getting accustomed with log4j 2. It is awesome so far. However, i can't figure out how to create a routing logger with the ConfigurationBuilder API. I came this far:
>> AppenderComponentBuilder routingAppender = builder.newAppender("Routing", "Routing");
>>
>> And then what, how do you configure the <Routes> and each <Route>?
>> Some input would be greatly appreciated!
>>
>> Also, the OutputStreamAppender's Builder seems to be missing a few annotations (@PluginBuilderAttribute & @Required), compared to the one in ConsoleAppender.
>>
>> Best regards
>> Jens Schmidt
>>
>> --
>> Dipl.-Ing. Jens Schmidt
>> Telefon: 0711/217-24901-2
>> Email: [hidden email]
>>
>> IILS Ingenieurgesellschaft für Intelligente Lösungen und Systeme mbH
>> Albstrasse 6, D-72818 Trochtelfingen-Steinhilben
>> Geschäftsführer Dipl.-Ing. Peter Arnold und Dipl.-Ing. Roland Weil
>> USt-IDNr.: DE 203557532
>> Registergericht: Amtsgericht Stuttgart
>> Handelsregister: Ingenieurkammer Baden-Württemberg HRB 20422
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
>

--
Dipl.-Ing. Jens Schmidt
Telefon: 0711/217-24901-2
Email: [hidden email]

IILS Ingenieurgesellschaft für Intelligente Lösungen und Systeme mbH
Albstrasse 6, D-72818 Trochtelfingen-Steinhilben
Geschäftsführer Dipl.-Ing. Peter Arnold und Dipl.-Ing. Roland Weil
USt-IDNr.: DE 203557532
Registergericht: Amtsgericht Stuttgart
Handelsregister: Ingenieurkammer Baden-Württemberg HRB 20422

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

Reply | Threaded
Open this post in threaded view
|

Re: How to build the Routing Appender with the ConfigurationBuilder

Ralph Goers
This one has me stumped. I don’t recall when OutputStreamAppender or WriterAppender were added or why but they are unlike any other Appenders. The documentation on OutputStreamAppender is wrong by the way, It says it is used by other Appenders but that isn’t the case. All the other use AbstractOutputStreamAppender. I have no idea why OutputStreamAppender or WriterAppender exist or how you are supposed to use them.

Ralph



> On Dec 21, 2017, at 12:02 PM, Jens Schmidt <[hidden email]> wrote:
>
> Hello Ralph,
>
> thank you for your answer. That worked for the most part!
> However using the CompnentBuilder i am not able to create an OutputStreamAppender.
>
> I looked into the Code and the internal Builder Classes of the OutputStreamAppender and the WriterAppender are defined differently compared to, e.g. the ConsoleAppender. I believe this to be a bug?.
>
> Cheers Jens
>
>
>
> Am 27.11.2017 um 18:36 schrieb Ralph Goers:
>> What you need to know is that with the ConfigurationBuilder everything is really a Component. Since Layouts, Appenders, Filters and Loggers are so common we have built specialized ComponentBuilders for them, but they could also be constructed with a generic ComponentBuilder. https://logging.apache.org/log4j/2.x/manual/customconfig.html <https://logging.apache.org/log4j/2.x/manual/customconfig.html> provides some examples that show creating triggering policies using the generic ComponentBuilder. You can use that as a guide to help you figure out how to construct your routes.
>> Ralph
>>> On Nov 27, 2017, at 9:29 AM, Jens Schmidt <[hidden email]> wrote:
>>>
>>>
>>> Hello there,
>>>
>>> getting accustomed with log4j 2. It is awesome so far. However, i can't figure out how to create a routing logger with the ConfigurationBuilder API. I came this far:
>>> AppenderComponentBuilder routingAppender = builder.newAppender("Routing", "Routing");
>>>
>>> And then what, how do you configure the <Routes> and each <Route>?
>>> Some input would be greatly appreciated!
>>>
>>> Also, the OutputStreamAppender's Builder seems to be missing a few annotations (@PluginBuilderAttribute & @Required), compared to the one in ConsoleAppender.
>>>
>>> Best regards
>>> Jens Schmidt
>>>
>>> --
>>> Dipl.-Ing. Jens Schmidt
>>> Telefon: 0711/217-24901-2
>>> Email: [hidden email]
>>>
>>> IILS Ingenieurgesellschaft für Intelligente Lösungen und Systeme mbH
>>> Albstrasse 6, D-72818 Trochtelfingen-Steinhilben
>>> Geschäftsführer Dipl.-Ing. Peter Arnold und Dipl.-Ing. Roland Weil
>>> USt-IDNr.: DE 203557532
>>> Registergericht: Amtsgericht Stuttgart
>>> Handelsregister: Ingenieurkammer Baden-Württemberg HRB 20422
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>
> --
> Dipl.-Ing. Jens Schmidt
> Telefon: 0711/217-24901-2
> Email: [hidden email]
>
> IILS Ingenieurgesellschaft für Intelligente Lösungen und Systeme mbH
> Albstrasse 6, D-72818 Trochtelfingen-Steinhilben
> Geschäftsführer Dipl.-Ing. Peter Arnold und Dipl.-Ing. Roland Weil
> USt-IDNr.: DE 203557532
> Registergericht: Amtsgericht Stuttgart
> Handelsregister: Ingenieurkammer Baden-Württemberg HRB 20422
>
> ---------------------------------------------------------------------
> 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: How to build the Routing Appender with the ConfigurationBuilder

Remko Popma-2
I suppose that was done for the streams module, to allow installing Log4j2 on jdbc drivers.

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

> On Dec 22, 2017, at 4:55, Ralph Goers <[hidden email]> wrote:
>
> This one has me stumped. I don’t recall when OutputStreamAppender or WriterAppender were added or why but they are unlike any other Appenders. The documentation on OutputStreamAppender is wrong by the way, It says it is used by other Appenders but that isn’t the case. All the other use AbstractOutputStreamAppender. I have no idea why OutputStreamAppender or WriterAppender exist or how you are supposed to use them.
>
> Ralph
>
>
>
>> On Dec 21, 2017, at 12:02 PM, Jens Schmidt <[hidden email]> wrote:
>>
>> Hello Ralph,
>>
>> thank you for your answer. That worked for the most part!
>> However using the CompnentBuilder i am not able to create an OutputStreamAppender.
>>
>> I looked into the Code and the internal Builder Classes of the OutputStreamAppender and the WriterAppender are defined differently compared to, e.g. the ConsoleAppender. I believe this to be a bug?.
>>
>> Cheers Jens
>>
>>
>>
>>> Am 27.11.2017 um 18:36 schrieb Ralph Goers:
>>> What you need to know is that with the ConfigurationBuilder everything is really a Component. Since Layouts, Appenders, Filters and Loggers are so common we have built specialized ComponentBuilders for them, but they could also be constructed with a generic ComponentBuilder. https://logging.apache.org/log4j/2.x/manual/customconfig.html <https://logging.apache.org/log4j/2.x/manual/customconfig.html> provides some examples that show creating triggering policies using the generic ComponentBuilder. You can use that as a guide to help you figure out how to construct your routes.
>>> Ralph
>>>> On Nov 27, 2017, at 9:29 AM, Jens Schmidt <[hidden email]> wrote:
>>>>
>>>>
>>>> Hello there,
>>>>
>>>> getting accustomed with log4j 2. It is awesome so far. However, i can't figure out how to create a routing logger with the ConfigurationBuilder API. I came this far:
>>>> AppenderComponentBuilder routingAppender = builder.newAppender("Routing", "Routing");
>>>>
>>>> And then what, how do you configure the <Routes> and each <Route>?
>>>> Some input would be greatly appreciated!
>>>>
>>>> Also, the OutputStreamAppender's Builder seems to be missing a few annotations (@PluginBuilderAttribute & @Required), compared to the one in ConsoleAppender.
>>>>
>>>> Best regards
>>>> Jens Schmidt
>>>>
>>>> --
>>>> Dipl.-Ing. Jens Schmidt
>>>> Telefon: 0711/217-24901-2
>>>> Email: [hidden email]
>>>>
>>>> IILS Ingenieurgesellschaft für Intelligente Lösungen und Systeme mbH
>>>> Albstrasse 6, D-72818 Trochtelfingen-Steinhilben
>>>> Geschäftsführer Dipl.-Ing. Peter Arnold und Dipl.-Ing. Roland Weil
>>>> USt-IDNr.: DE 203557532
>>>> Registergericht: Amtsgericht Stuttgart
>>>> Handelsregister: Ingenieurkammer Baden-Württemberg HRB 20422
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>>
>> --
>> Dipl.-Ing. Jens Schmidt
>> Telefon: 0711/217-24901-2
>> Email: [hidden email]
>>
>> IILS Ingenieurgesellschaft für Intelligente Lösungen und Systeme mbH
>> Albstrasse 6, D-72818 Trochtelfingen-Steinhilben
>> Geschäftsführer Dipl.-Ing. Peter Arnold und Dipl.-Ing. Roland Weil
>> USt-IDNr.: DE 203557532
>> Registergericht: Amtsgericht Stuttgart
>> Handelsregister: Ingenieurkammer Baden-Württemberg HRB 20422
>>
>> ---------------------------------------------------------------------
>> 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: How to build the Routing Appender with the ConfigurationBuilder

Gary Gregory-4
On Thu, Dec 21, 2017 at 3:45 PM, Remko Popma <[hidden email]> wrote:

> I suppose that was done for the streams module, to allow installing Log4j2
> on jdbc drivers.
>

Correct. I wrote a JDBC driver that uses Log4j 2 but this is useful for any
JDBC Driver where you want that driver to log to Log4j instead of a
PrintWriter; which is what JDBC forces you to use.

From the Javdoc for org.apache.logging.log4j.io.LoggerPrintWriter:

     PrintWriter pw =
IoBuilder.forLogger().setLevel(Level.DEBUG).buildPrintWriter();
     DriverManager.setLogWriter(pw);
     DataSource ds = ...
     ds.setLogWriter(pw);

Gary


> (Shameless plug) Every java main() method deserves http://picocli.info
>
> > On Dec 22, 2017, at 4:55, Ralph Goers <[hidden email]>
> wrote:
> >
> > This one has me stumped. I don’t recall when OutputStreamAppender or
> WriterAppender were added or why but they are unlike any other Appenders.
> The documentation on OutputStreamAppender is wrong by the way, It says it
> is used by other Appenders but that isn’t the case. All the other use
> AbstractOutputStreamAppender. I have no idea why OutputStreamAppender or
> WriterAppender exist or how you are supposed to use them.
> >
> > Ralph
> >
> >
> >
> >> On Dec 21, 2017, at 12:02 PM, Jens Schmidt <[hidden email]> wrote:
> >>
> >> Hello Ralph,
> >>
> >> thank you for your answer. That worked for the most part!
> >> However using the CompnentBuilder i am not able to create an
> OutputStreamAppender.
> >>
> >> I looked into the Code and the internal Builder Classes of the
> OutputStreamAppender and the WriterAppender are defined differently
> compared to, e.g. the ConsoleAppender. I believe this to be a bug?.
> >>
> >> Cheers Jens
> >>
> >>
> >>
> >>> Am 27.11.2017 um 18:36 schrieb Ralph Goers:
> >>> What you need to know is that with the ConfigurationBuilder everything
> is really a Component. Since Layouts, Appenders, Filters and Loggers are so
> common we have built specialized ComponentBuilders for them, but they could
> also be constructed with a generic ComponentBuilder.
> https://logging.apache.org/log4j/2.x/manual/customconfig.html <
> https://logging.apache.org/log4j/2.x/manual/customconfig.html> provides
> some examples that show creating triggering policies using the generic
> ComponentBuilder. You can use that as a guide to help you figure out how to
> construct your routes.
> >>> Ralph
> >>>> On Nov 27, 2017, at 9:29 AM, Jens Schmidt <[hidden email]> wrote:
> >>>>
> >>>>
> >>>> Hello there,
> >>>>
> >>>> getting accustomed with log4j 2. It is awesome so far. However, i
> can't figure out how to create a routing logger with the
> ConfigurationBuilder API. I came this far:
> >>>> AppenderComponentBuilder routingAppender =
> builder.newAppender("Routing", "Routing");
> >>>>
> >>>> And then what, how do you configure the <Routes> and each <Route>?
> >>>> Some input would be greatly appreciated!
> >>>>
> >>>> Also, the OutputStreamAppender's Builder seems to be missing a few
> annotations (@PluginBuilderAttribute & @Required), compared to the one in
> ConsoleAppender.
> >>>>
> >>>> Best regards
> >>>> Jens Schmidt
> >>>>
> >>>> --
> >>>> Dipl.-Ing. Jens Schmidt
> >>>> Telefon: 0711/217-24901-2
> >>>> Email: [hidden email]
> >>>>
> >>>> IILS Ingenieurgesellschaft für Intelligente Lösungen und Systeme mbH
> >>>> Albstrasse 6, D-72818 Trochtelfingen-Steinhilben
> >>>> Geschäftsführer Dipl.-Ing. Peter Arnold und Dipl.-Ing. Roland Weil
> >>>> USt-IDNr.: DE 203557532
> >>>> Registergericht: Amtsgericht Stuttgart
> >>>> Handelsregister: Ingenieurkammer Baden-Württemberg HRB 20422
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: [hidden email]
> >>>> For additional commands, e-mail: [hidden email]
> >>>>
> >>>>
> >>
> >> --
> >> Dipl.-Ing. Jens Schmidt
> >> Telefon: 0711/217-24901-2
> >> Email: [hidden email]
> >>
> >> IILS Ingenieurgesellschaft für Intelligente Lösungen und Systeme mbH
> >> Albstrasse 6, D-72818 Trochtelfingen-Steinhilben
> >> Geschäftsführer Dipl.-Ing. Peter Arnold und Dipl.-Ing. Roland Weil
> >> USt-IDNr.: DE 203557532
> >> Registergericht: Amtsgericht Stuttgart
> >> Handelsregister: Ingenieurkammer Baden-Württemberg HRB 20422
> >>
> >> ---------------------------------------------------------------------
> >> 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]
>
>