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 lb <lb...@gmail.com> on 2014/08/28 12:13:52 UTC

Custom appender : PluginElement

I'm writing a custom appender and I have a problem setting up PluginElement:

The xml definition is the following one:

 <BinaryVanillaChronicle name="CONF-BINARY-VANILLA-CHRONICLE">

<path>${sys:java.io.tmpdir}/chronology-log4j2/conf-binary-vanilla-chronicle</path>
    <formatMessage>false</formatMessage>
    <includeCallerData>false</includeCallerData>
    <includeMappedDiagnosticContext>false</includeMappedDiagnosticContext>
    <chronicleConfig>
        <dataCacheCapacity>128</dataCacheCapacity>
    </chronicleConfig>
</BinaryVanillaChronicle>

And the PluginFactory method is:
@PluginFactory
public static BinaryVanillaChronicleAppender createAppender(
    @PluginAttribute("name") final String name,
    @PluginAttribute("path") final String path,
    @PluginAttribute("formatMessage") final String formatMessage,
    @PluginAttribute("includeCallerData") final String includeCallerData,
    @PluginAttribute("includeMappedDiagnosticContext") final String
includeMappedDiagnosticContext,
    @PluginElement("chronicleConfig") final VanillaLogAppenderConfig
chronicleConfig,
    @PluginElement("filters") final Filter filter)

When I run it, I have the following messages:
2014-08-28 12:12:29,247 ERROR appenders contains an invalid element or
attribute "BinaryVanillaChronicle"
2014-08-28 12:12:29,267 ERROR Unable to locate appender
BINARY-VANILLA-CHRONICLE for logger binary-vanilla-chronicle
2014-08-28 12:12:29,268 ERROR Unable to locate appender
BINARY-VANILLA-CHRONICLE-FMT for logger binary-vanilla-chronicle-fmt
2014-08-28 12:12:29,268 ERROR Unable to locate appender
PERF-BINARY-VANILLA-CHRONICLE for logger perf-binary-vanilla-chronicle

The full code is on
https://github.com/lburgazzoli/Chronicle-Logger/tree/HFT-CLOG-12/logger-log4j-2

What's wrong with my setup?

Re: Custom appender : PluginElement

Posted by Matt Sicker <bo...@gmail.com>.
Alright. That would mean you need to use @PluginAliases if you want to
support other element names besides the plugin name. The JMS Appender is
actually using that right now in the master branch.


On 6 September 2014 07:26, lb <lb...@gmail.com> wrote:

> I did a test but if the @PluginElement does not match @Plugin it fails
> with:
>
> 2014-09-06 14:22:26,335 ERROR BinaryVanillaChronicle contains an invalid
> element or attribute "chronicleConfig"
> 2014-09-06 14:22:26,341 ERROR TextVanillaChronicle contains an invalid
> element or attribute "chronicleConfig"
> 2014-09-06 14:22:26,344 ERROR BinaryIndexedChronicle contains an invalid
> element or attribute "chronicleConfig"
> 2014-09-06 14:22:26,348 ERROR TextIndexedChronicle contains an invalid
> element or attribute "chronicleConfig"
>
>
> On Sun, Aug 31, 2014 at 8:33 PM, Matt Sicker <bo...@gmail.com> wrote:
>
> > I think you can use different values for @PluginElement than you do for
> > @Plugin which helps in the XML/JSON format. I'd have to look into this
> > more.
> >
> >
> > On 31 August 2014 10:23, lb <lb...@gmail.com> wrote:
> >
> > > I think you should explicit state that every @PluginElement should be a
> > > "Plugin" then it is clear.  As consequence, there is a little problem
> as
> > > you can't have two nested elements with the same name, i.e.
> > >
> > > <AppenderA>
> > >   <Configuration>
> > >   ....
> > >   </Configuration>
> > > </AppenderA>
> > >
> > > <AppenderB>
> > >   <Configuration>
> > >   ....
> > >   </Configuration>
> > > </AppenderB>
> > >
> > > Assume that AppenderA and AppenderB are two different appender and they
> > > need a specific configuration object (AppenderA.Configuration.class !=
> > > AppenderB.Configuration.class). I would love to use Configuration for
> > both
> > > appenders but I can't as the name is set by @Plugin and
> @PluginElement,
> > am
> > > I wrong?
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Sat, Aug 30, 2014 at 9:03 PM, Matt Sicker <bo...@gmail.com> wrote:
> > >
> > > > Good to hear it! Is there anything about the documentation you found
> > > > unclear in that regard?
> > > >
> > > >
> > > > On 30 August 2014 01:44, lb <lb...@gmail.com> wrote:
> > > >
> > > > > Yes that was the problem, I forgot to mark it as plugin. Now it
> > works,
> > > > > thank you
> > > > >
> > > > > On Friday, August 29, 2014, Matt Sicker <bo...@gmail.com> wrote:
> > > > >
> > > > > > Is VanillaLogAppenderConfig also marked as a @Plugin and
> > everything?
> > > > > >
> > > > > >
> > > > > > On 28 August 2014 05:13, lb <lburgazzoli@gmail.com
> <javascript:;>>
> > > > > wrote:
> > > > > >
> > > > > > > I'm writing a custom appender and I have a problem setting up
> > > > > > > PluginElement:
> > > > > > >
> > > > > > > The xml definition is the following one:
> > > > > > >
> > > > > > >  <BinaryVanillaChronicle name="CONF-BINARY-VANILLA-CHRONICLE">
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> <path>${sys:java.io.tmpdir}/chronology-log4j2/conf-binary-vanilla-chronicle</path>
> > > > > > >     <formatMessage>false</formatMessage>
> > > > > > >     <includeCallerData>false</includeCallerData>
> > > > > > >
> > > > > >
> > > <includeMappedDiagnosticContext>false</includeMappedDiagnosticContext>
> > > > > > >     <chronicleConfig>
> > > > > > >         <dataCacheCapacity>128</dataCacheCapacity>
> > > > > > >     </chronicleConfig>
> > > > > > > </BinaryVanillaChronicle>
> > > > > > >
> > > > > > > And the PluginFactory method is:
> > > > > > > @PluginFactory
> > > > > > > public static BinaryVanillaChronicleAppender createAppender(
> > > > > > >     @PluginAttribute("name") final String name,
> > > > > > >     @PluginAttribute("path") final String path,
> > > > > > >     @PluginAttribute("formatMessage") final String
> formatMessage,
> > > > > > >     @PluginAttribute("includeCallerData") final String
> > > > > includeCallerData,
> > > > > > >     @PluginAttribute("includeMappedDiagnosticContext") final
> > String
> > > > > > > includeMappedDiagnosticContext,
> > > > > > >     @PluginElement("chronicleConfig") final
> > > VanillaLogAppenderConfig
> > > > > > > chronicleConfig,
> > > > > > >     @PluginElement("filters") final Filter filter)
> > > > > > >
> > > > > > > When I run it, I have the following messages:
> > > > > > > 2014-08-28 12:12:29,247 ERROR appenders contains an invalid
> > element
> > > > or
> > > > > > > attribute "BinaryVanillaChronicle"
> > > > > > > 2014-08-28 12:12:29,267 ERROR Unable to locate appender
> > > > > > > BINARY-VANILLA-CHRONICLE for logger binary-vanilla-chronicle
> > > > > > > 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> > > > > > > BINARY-VANILLA-CHRONICLE-FMT for logger
> > > binary-vanilla-chronicle-fmt
> > > > > > > 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> > > > > > > PERF-BINARY-VANILLA-CHRONICLE for logger
> > > > perf-binary-vanilla-chronicle
> > > > > > >
> > > > > > > The full code is on
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/lburgazzoli/Chronicle-Logger/tree/HFT-CLOG-12/logger-log4j-2
> > > > > > >
> > > > > > > What's wrong with my setup?
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Matt Sicker <boards@gmail.com <javascript:;>>
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Matt Sicker <bo...@gmail.com>
> > > >
> > >
> >
> >
> >
> > --
> > Matt Sicker <bo...@gmail.com>
> >
>



-- 
Matt Sicker <bo...@gmail.com>

Re: Custom appender : PluginElement

Posted by lb <lb...@gmail.com>.
I did a test but if the @PluginElement does not match @Plugin it fails with:

2014-09-06 14:22:26,335 ERROR BinaryVanillaChronicle contains an invalid
element or attribute "chronicleConfig"
2014-09-06 14:22:26,341 ERROR TextVanillaChronicle contains an invalid
element or attribute "chronicleConfig"
2014-09-06 14:22:26,344 ERROR BinaryIndexedChronicle contains an invalid
element or attribute "chronicleConfig"
2014-09-06 14:22:26,348 ERROR TextIndexedChronicle contains an invalid
element or attribute "chronicleConfig"


On Sun, Aug 31, 2014 at 8:33 PM, Matt Sicker <bo...@gmail.com> wrote:

> I think you can use different values for @PluginElement than you do for
> @Plugin which helps in the XML/JSON format. I'd have to look into this
> more.
>
>
> On 31 August 2014 10:23, lb <lb...@gmail.com> wrote:
>
> > I think you should explicit state that every @PluginElement should be a
> > "Plugin" then it is clear.  As consequence, there is a little problem as
> > you can't have two nested elements with the same name, i.e.
> >
> > <AppenderA>
> >   <Configuration>
> >   ....
> >   </Configuration>
> > </AppenderA>
> >
> > <AppenderB>
> >   <Configuration>
> >   ....
> >   </Configuration>
> > </AppenderB>
> >
> > Assume that AppenderA and AppenderB are two different appender and they
> > need a specific configuration object (AppenderA.Configuration.class !=
> > AppenderB.Configuration.class). I would love to use Configuration for
> both
> > appenders but I can't as the name is set by @Plugin and  @PluginElement,
> am
> > I wrong?
> >
> >
> >
> >
> >
> >
> >
> >
> > On Sat, Aug 30, 2014 at 9:03 PM, Matt Sicker <bo...@gmail.com> wrote:
> >
> > > Good to hear it! Is there anything about the documentation you found
> > > unclear in that regard?
> > >
> > >
> > > On 30 August 2014 01:44, lb <lb...@gmail.com> wrote:
> > >
> > > > Yes that was the problem, I forgot to mark it as plugin. Now it
> works,
> > > > thank you
> > > >
> > > > On Friday, August 29, 2014, Matt Sicker <bo...@gmail.com> wrote:
> > > >
> > > > > Is VanillaLogAppenderConfig also marked as a @Plugin and
> everything?
> > > > >
> > > > >
> > > > > On 28 August 2014 05:13, lb <lburgazzoli@gmail.com <javascript:;>>
> > > > wrote:
> > > > >
> > > > > > I'm writing a custom appender and I have a problem setting up
> > > > > > PluginElement:
> > > > > >
> > > > > > The xml definition is the following one:
> > > > > >
> > > > > >  <BinaryVanillaChronicle name="CONF-BINARY-VANILLA-CHRONICLE">
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> <path>${sys:java.io.tmpdir}/chronology-log4j2/conf-binary-vanilla-chronicle</path>
> > > > > >     <formatMessage>false</formatMessage>
> > > > > >     <includeCallerData>false</includeCallerData>
> > > > > >
> > > > >
> > <includeMappedDiagnosticContext>false</includeMappedDiagnosticContext>
> > > > > >     <chronicleConfig>
> > > > > >         <dataCacheCapacity>128</dataCacheCapacity>
> > > > > >     </chronicleConfig>
> > > > > > </BinaryVanillaChronicle>
> > > > > >
> > > > > > And the PluginFactory method is:
> > > > > > @PluginFactory
> > > > > > public static BinaryVanillaChronicleAppender createAppender(
> > > > > >     @PluginAttribute("name") final String name,
> > > > > >     @PluginAttribute("path") final String path,
> > > > > >     @PluginAttribute("formatMessage") final String formatMessage,
> > > > > >     @PluginAttribute("includeCallerData") final String
> > > > includeCallerData,
> > > > > >     @PluginAttribute("includeMappedDiagnosticContext") final
> String
> > > > > > includeMappedDiagnosticContext,
> > > > > >     @PluginElement("chronicleConfig") final
> > VanillaLogAppenderConfig
> > > > > > chronicleConfig,
> > > > > >     @PluginElement("filters") final Filter filter)
> > > > > >
> > > > > > When I run it, I have the following messages:
> > > > > > 2014-08-28 12:12:29,247 ERROR appenders contains an invalid
> element
> > > or
> > > > > > attribute "BinaryVanillaChronicle"
> > > > > > 2014-08-28 12:12:29,267 ERROR Unable to locate appender
> > > > > > BINARY-VANILLA-CHRONICLE for logger binary-vanilla-chronicle
> > > > > > 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> > > > > > BINARY-VANILLA-CHRONICLE-FMT for logger
> > binary-vanilla-chronicle-fmt
> > > > > > 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> > > > > > PERF-BINARY-VANILLA-CHRONICLE for logger
> > > perf-binary-vanilla-chronicle
> > > > > >
> > > > > > The full code is on
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/lburgazzoli/Chronicle-Logger/tree/HFT-CLOG-12/logger-log4j-2
> > > > > >
> > > > > > What's wrong with my setup?
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Matt Sicker <boards@gmail.com <javascript:;>>
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Matt Sicker <bo...@gmail.com>
> > >
> >
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>

Re: Custom appender : PluginElement

Posted by Matt Sicker <bo...@gmail.com>.
I think you can use different values for @PluginElement than you do for
@Plugin which helps in the XML/JSON format. I'd have to look into this more.


On 31 August 2014 10:23, lb <lb...@gmail.com> wrote:

> I think you should explicit state that every @PluginElement should be a
> "Plugin" then it is clear.  As consequence, there is a little problem as
> you can't have two nested elements with the same name, i.e.
>
> <AppenderA>
>   <Configuration>
>   ....
>   </Configuration>
> </AppenderA>
>
> <AppenderB>
>   <Configuration>
>   ....
>   </Configuration>
> </AppenderB>
>
> Assume that AppenderA and AppenderB are two different appender and they
> need a specific configuration object (AppenderA.Configuration.class !=
> AppenderB.Configuration.class). I would love to use Configuration for both
> appenders but I can't as the name is set by @Plugin and  @PluginElement, am
> I wrong?
>
>
>
>
>
>
>
>
> On Sat, Aug 30, 2014 at 9:03 PM, Matt Sicker <bo...@gmail.com> wrote:
>
> > Good to hear it! Is there anything about the documentation you found
> > unclear in that regard?
> >
> >
> > On 30 August 2014 01:44, lb <lb...@gmail.com> wrote:
> >
> > > Yes that was the problem, I forgot to mark it as plugin. Now it works,
> > > thank you
> > >
> > > On Friday, August 29, 2014, Matt Sicker <bo...@gmail.com> wrote:
> > >
> > > > Is VanillaLogAppenderConfig also marked as a @Plugin and everything?
> > > >
> > > >
> > > > On 28 August 2014 05:13, lb <lburgazzoli@gmail.com <javascript:;>>
> > > wrote:
> > > >
> > > > > I'm writing a custom appender and I have a problem setting up
> > > > > PluginElement:
> > > > >
> > > > > The xml definition is the following one:
> > > > >
> > > > >  <BinaryVanillaChronicle name="CONF-BINARY-VANILLA-CHRONICLE">
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> <path>${sys:java.io.tmpdir}/chronology-log4j2/conf-binary-vanilla-chronicle</path>
> > > > >     <formatMessage>false</formatMessage>
> > > > >     <includeCallerData>false</includeCallerData>
> > > > >
> > > >
> <includeMappedDiagnosticContext>false</includeMappedDiagnosticContext>
> > > > >     <chronicleConfig>
> > > > >         <dataCacheCapacity>128</dataCacheCapacity>
> > > > >     </chronicleConfig>
> > > > > </BinaryVanillaChronicle>
> > > > >
> > > > > And the PluginFactory method is:
> > > > > @PluginFactory
> > > > > public static BinaryVanillaChronicleAppender createAppender(
> > > > >     @PluginAttribute("name") final String name,
> > > > >     @PluginAttribute("path") final String path,
> > > > >     @PluginAttribute("formatMessage") final String formatMessage,
> > > > >     @PluginAttribute("includeCallerData") final String
> > > includeCallerData,
> > > > >     @PluginAttribute("includeMappedDiagnosticContext") final String
> > > > > includeMappedDiagnosticContext,
> > > > >     @PluginElement("chronicleConfig") final
> VanillaLogAppenderConfig
> > > > > chronicleConfig,
> > > > >     @PluginElement("filters") final Filter filter)
> > > > >
> > > > > When I run it, I have the following messages:
> > > > > 2014-08-28 12:12:29,247 ERROR appenders contains an invalid element
> > or
> > > > > attribute "BinaryVanillaChronicle"
> > > > > 2014-08-28 12:12:29,267 ERROR Unable to locate appender
> > > > > BINARY-VANILLA-CHRONICLE for logger binary-vanilla-chronicle
> > > > > 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> > > > > BINARY-VANILLA-CHRONICLE-FMT for logger
> binary-vanilla-chronicle-fmt
> > > > > 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> > > > > PERF-BINARY-VANILLA-CHRONICLE for logger
> > perf-binary-vanilla-chronicle
> > > > >
> > > > > The full code is on
> > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/lburgazzoli/Chronicle-Logger/tree/HFT-CLOG-12/logger-log4j-2
> > > > >
> > > > > What's wrong with my setup?
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Matt Sicker <boards@gmail.com <javascript:;>>
> > > >
> > >
> >
> >
> >
> > --
> > Matt Sicker <bo...@gmail.com>
> >
>



-- 
Matt Sicker <bo...@gmail.com>

Re: Custom appender : PluginElement

Posted by lb <lb...@gmail.com>.
I think you should explicit state that every @PluginElement should be a
"Plugin" then it is clear.  As consequence, there is a little problem as
you can't have two nested elements with the same name, i.e.

<AppenderA>
  <Configuration>
  ....
  </Configuration>
</AppenderA>

<AppenderB>
  <Configuration>
  ....
  </Configuration>
</AppenderB>

Assume that AppenderA and AppenderB are two different appender and they
need a specific configuration object (AppenderA.Configuration.class !=
AppenderB.Configuration.class). I would love to use Configuration for both
appenders but I can't as the name is set by @Plugin and  @PluginElement, am
I wrong?








On Sat, Aug 30, 2014 at 9:03 PM, Matt Sicker <bo...@gmail.com> wrote:

> Good to hear it! Is there anything about the documentation you found
> unclear in that regard?
>
>
> On 30 August 2014 01:44, lb <lb...@gmail.com> wrote:
>
> > Yes that was the problem, I forgot to mark it as plugin. Now it works,
> > thank you
> >
> > On Friday, August 29, 2014, Matt Sicker <bo...@gmail.com> wrote:
> >
> > > Is VanillaLogAppenderConfig also marked as a @Plugin and everything?
> > >
> > >
> > > On 28 August 2014 05:13, lb <lburgazzoli@gmail.com <javascript:;>>
> > wrote:
> > >
> > > > I'm writing a custom appender and I have a problem setting up
> > > > PluginElement:
> > > >
> > > > The xml definition is the following one:
> > > >
> > > >  <BinaryVanillaChronicle name="CONF-BINARY-VANILLA-CHRONICLE">
> > > >
> > > >
> > > >
> > >
> >
> <path>${sys:java.io.tmpdir}/chronology-log4j2/conf-binary-vanilla-chronicle</path>
> > > >     <formatMessage>false</formatMessage>
> > > >     <includeCallerData>false</includeCallerData>
> > > >
> > >  <includeMappedDiagnosticContext>false</includeMappedDiagnosticContext>
> > > >     <chronicleConfig>
> > > >         <dataCacheCapacity>128</dataCacheCapacity>
> > > >     </chronicleConfig>
> > > > </BinaryVanillaChronicle>
> > > >
> > > > And the PluginFactory method is:
> > > > @PluginFactory
> > > > public static BinaryVanillaChronicleAppender createAppender(
> > > >     @PluginAttribute("name") final String name,
> > > >     @PluginAttribute("path") final String path,
> > > >     @PluginAttribute("formatMessage") final String formatMessage,
> > > >     @PluginAttribute("includeCallerData") final String
> > includeCallerData,
> > > >     @PluginAttribute("includeMappedDiagnosticContext") final String
> > > > includeMappedDiagnosticContext,
> > > >     @PluginElement("chronicleConfig") final VanillaLogAppenderConfig
> > > > chronicleConfig,
> > > >     @PluginElement("filters") final Filter filter)
> > > >
> > > > When I run it, I have the following messages:
> > > > 2014-08-28 12:12:29,247 ERROR appenders contains an invalid element
> or
> > > > attribute "BinaryVanillaChronicle"
> > > > 2014-08-28 12:12:29,267 ERROR Unable to locate appender
> > > > BINARY-VANILLA-CHRONICLE for logger binary-vanilla-chronicle
> > > > 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> > > > BINARY-VANILLA-CHRONICLE-FMT for logger binary-vanilla-chronicle-fmt
> > > > 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> > > > PERF-BINARY-VANILLA-CHRONICLE for logger
> perf-binary-vanilla-chronicle
> > > >
> > > > The full code is on
> > > >
> > > >
> > >
> >
> https://github.com/lburgazzoli/Chronicle-Logger/tree/HFT-CLOG-12/logger-log4j-2
> > > >
> > > > What's wrong with my setup?
> > > >
> > >
> > >
> > >
> > > --
> > > Matt Sicker <boards@gmail.com <javascript:;>>
> > >
> >
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>

Re: Custom appender : PluginElement

Posted by Matt Sicker <bo...@gmail.com>.
Good to hear it! Is there anything about the documentation you found
unclear in that regard?


On 30 August 2014 01:44, lb <lb...@gmail.com> wrote:

> Yes that was the problem, I forgot to mark it as plugin. Now it works,
> thank you
>
> On Friday, August 29, 2014, Matt Sicker <bo...@gmail.com> wrote:
>
> > Is VanillaLogAppenderConfig also marked as a @Plugin and everything?
> >
> >
> > On 28 August 2014 05:13, lb <lburgazzoli@gmail.com <javascript:;>>
> wrote:
> >
> > > I'm writing a custom appender and I have a problem setting up
> > > PluginElement:
> > >
> > > The xml definition is the following one:
> > >
> > >  <BinaryVanillaChronicle name="CONF-BINARY-VANILLA-CHRONICLE">
> > >
> > >
> > >
> >
> <path>${sys:java.io.tmpdir}/chronology-log4j2/conf-binary-vanilla-chronicle</path>
> > >     <formatMessage>false</formatMessage>
> > >     <includeCallerData>false</includeCallerData>
> > >
> >  <includeMappedDiagnosticContext>false</includeMappedDiagnosticContext>
> > >     <chronicleConfig>
> > >         <dataCacheCapacity>128</dataCacheCapacity>
> > >     </chronicleConfig>
> > > </BinaryVanillaChronicle>
> > >
> > > And the PluginFactory method is:
> > > @PluginFactory
> > > public static BinaryVanillaChronicleAppender createAppender(
> > >     @PluginAttribute("name") final String name,
> > >     @PluginAttribute("path") final String path,
> > >     @PluginAttribute("formatMessage") final String formatMessage,
> > >     @PluginAttribute("includeCallerData") final String
> includeCallerData,
> > >     @PluginAttribute("includeMappedDiagnosticContext") final String
> > > includeMappedDiagnosticContext,
> > >     @PluginElement("chronicleConfig") final VanillaLogAppenderConfig
> > > chronicleConfig,
> > >     @PluginElement("filters") final Filter filter)
> > >
> > > When I run it, I have the following messages:
> > > 2014-08-28 12:12:29,247 ERROR appenders contains an invalid element or
> > > attribute "BinaryVanillaChronicle"
> > > 2014-08-28 12:12:29,267 ERROR Unable to locate appender
> > > BINARY-VANILLA-CHRONICLE for logger binary-vanilla-chronicle
> > > 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> > > BINARY-VANILLA-CHRONICLE-FMT for logger binary-vanilla-chronicle-fmt
> > > 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> > > PERF-BINARY-VANILLA-CHRONICLE for logger perf-binary-vanilla-chronicle
> > >
> > > The full code is on
> > >
> > >
> >
> https://github.com/lburgazzoli/Chronicle-Logger/tree/HFT-CLOG-12/logger-log4j-2
> > >
> > > What's wrong with my setup?
> > >
> >
> >
> >
> > --
> > Matt Sicker <boards@gmail.com <javascript:;>>
> >
>



-- 
Matt Sicker <bo...@gmail.com>

Re: Custom appender : PluginElement

Posted by lb <lb...@gmail.com>.
Yes that was the problem, I forgot to mark it as plugin. Now it works,
thank you

On Friday, August 29, 2014, Matt Sicker <bo...@gmail.com> wrote:

> Is VanillaLogAppenderConfig also marked as a @Plugin and everything?
>
>
> On 28 August 2014 05:13, lb <lburgazzoli@gmail.com <javascript:;>> wrote:
>
> > I'm writing a custom appender and I have a problem setting up
> > PluginElement:
> >
> > The xml definition is the following one:
> >
> >  <BinaryVanillaChronicle name="CONF-BINARY-VANILLA-CHRONICLE">
> >
> >
> >
> <path>${sys:java.io.tmpdir}/chronology-log4j2/conf-binary-vanilla-chronicle</path>
> >     <formatMessage>false</formatMessage>
> >     <includeCallerData>false</includeCallerData>
> >
>  <includeMappedDiagnosticContext>false</includeMappedDiagnosticContext>
> >     <chronicleConfig>
> >         <dataCacheCapacity>128</dataCacheCapacity>
> >     </chronicleConfig>
> > </BinaryVanillaChronicle>
> >
> > And the PluginFactory method is:
> > @PluginFactory
> > public static BinaryVanillaChronicleAppender createAppender(
> >     @PluginAttribute("name") final String name,
> >     @PluginAttribute("path") final String path,
> >     @PluginAttribute("formatMessage") final String formatMessage,
> >     @PluginAttribute("includeCallerData") final String includeCallerData,
> >     @PluginAttribute("includeMappedDiagnosticContext") final String
> > includeMappedDiagnosticContext,
> >     @PluginElement("chronicleConfig") final VanillaLogAppenderConfig
> > chronicleConfig,
> >     @PluginElement("filters") final Filter filter)
> >
> > When I run it, I have the following messages:
> > 2014-08-28 12:12:29,247 ERROR appenders contains an invalid element or
> > attribute "BinaryVanillaChronicle"
> > 2014-08-28 12:12:29,267 ERROR Unable to locate appender
> > BINARY-VANILLA-CHRONICLE for logger binary-vanilla-chronicle
> > 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> > BINARY-VANILLA-CHRONICLE-FMT for logger binary-vanilla-chronicle-fmt
> > 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> > PERF-BINARY-VANILLA-CHRONICLE for logger perf-binary-vanilla-chronicle
> >
> > The full code is on
> >
> >
> https://github.com/lburgazzoli/Chronicle-Logger/tree/HFT-CLOG-12/logger-log4j-2
> >
> > What's wrong with my setup?
> >
>
>
>
> --
> Matt Sicker <boards@gmail.com <javascript:;>>
>

Re: Custom appender : PluginElement

Posted by Matt Sicker <bo...@gmail.com>.
Is VanillaLogAppenderConfig also marked as a @Plugin and everything?


On 28 August 2014 05:13, lb <lb...@gmail.com> wrote:

> I'm writing a custom appender and I have a problem setting up
> PluginElement:
>
> The xml definition is the following one:
>
>  <BinaryVanillaChronicle name="CONF-BINARY-VANILLA-CHRONICLE">
>
>
> <path>${sys:java.io.tmpdir}/chronology-log4j2/conf-binary-vanilla-chronicle</path>
>     <formatMessage>false</formatMessage>
>     <includeCallerData>false</includeCallerData>
>     <includeMappedDiagnosticContext>false</includeMappedDiagnosticContext>
>     <chronicleConfig>
>         <dataCacheCapacity>128</dataCacheCapacity>
>     </chronicleConfig>
> </BinaryVanillaChronicle>
>
> And the PluginFactory method is:
> @PluginFactory
> public static BinaryVanillaChronicleAppender createAppender(
>     @PluginAttribute("name") final String name,
>     @PluginAttribute("path") final String path,
>     @PluginAttribute("formatMessage") final String formatMessage,
>     @PluginAttribute("includeCallerData") final String includeCallerData,
>     @PluginAttribute("includeMappedDiagnosticContext") final String
> includeMappedDiagnosticContext,
>     @PluginElement("chronicleConfig") final VanillaLogAppenderConfig
> chronicleConfig,
>     @PluginElement("filters") final Filter filter)
>
> When I run it, I have the following messages:
> 2014-08-28 12:12:29,247 ERROR appenders contains an invalid element or
> attribute "BinaryVanillaChronicle"
> 2014-08-28 12:12:29,267 ERROR Unable to locate appender
> BINARY-VANILLA-CHRONICLE for logger binary-vanilla-chronicle
> 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> BINARY-VANILLA-CHRONICLE-FMT for logger binary-vanilla-chronicle-fmt
> 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> PERF-BINARY-VANILLA-CHRONICLE for logger perf-binary-vanilla-chronicle
>
> The full code is on
>
> https://github.com/lburgazzoli/Chronicle-Logger/tree/HFT-CLOG-12/logger-log4j-2
>
> What's wrong with my setup?
>



-- 
Matt Sicker <bo...@gmail.com>

Re: Custom appender : PluginElement

Posted by Remko Popma <re...@gmail.com>.
It could be a problem with log4j2 not loading your custom plugin correctly.
It looks like you are building with maven.
Does the jar file generated by your build contain
a META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat
file?
If it doesn't you could try specifying the package "net.openhft.chronicle.
logger.log4j2" in the packages attribute of your log4j2.xml configuration.


What happens if you keep it simple and use this config (snippet):
 <BinaryVanillaChronicle
    name="CONF-BINARY-VANILLA-CHRONICLE"
    path="${sys:java.io.tmpdir}/chronology-log4j2/conf-binary-
vanilla-chronicle"
    formatMessage="false"
    includeCallerData="false"
    includeMappedDiagnosticContext="false"
/>

and leave out the nested <chronicleConfig> for now - I assume your plugin
will use some reasonable default here.
I want to use the simplest config possible first to just check if the
plugin is loaded correctly.




On Thu, Aug 28, 2014 at 7:13 PM, lb <lb...@gmail.com> wrote:

> I'm writing a custom appender and I have a problem setting up
> PluginElement:
>
> The xml definition is the following one:
>
>  <BinaryVanillaChronicle name="CONF-BINARY-VANILLA-CHRONICLE">
>
>
> <path>${sys:java.io.tmpdir}/chronology-log4j2/conf-binary-vanilla-chronicle</path>
>     <formatMessage>false</formatMessage>
>     <includeCallerData>false</includeCallerData>
>     <includeMappedDiagnosticContext>false</includeMappedDiagnosticContext>
>     <chronicleConfig>
>         <dataCacheCapacity>128</dataCacheCapacity>
>     </chronicleConfig>
> </BinaryVanillaChronicle>
>
> And the PluginFactory method is:
> @PluginFactory
> public static BinaryVanillaChronicleAppender createAppender(
>     @PluginAttribute("name") final String name,
>     @PluginAttribute("path") final String path,
>     @PluginAttribute("formatMessage") final String formatMessage,
>     @PluginAttribute("includeCallerData") final String includeCallerData,
>     @PluginAttribute("includeMappedDiagnosticContext") final String
> includeMappedDiagnosticContext,
>     @PluginElement("chronicleConfig") final VanillaLogAppenderConfig
> chronicleConfig,
>     @PluginElement("filters") final Filter filter)
>
> When I run it, I have the following messages:
> 2014-08-28 12:12:29,247 ERROR appenders contains an invalid element or
> attribute "BinaryVanillaChronicle"
> 2014-08-28 12:12:29,267 ERROR Unable to locate appender
> BINARY-VANILLA-CHRONICLE for logger binary-vanilla-chronicle
> 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> BINARY-VANILLA-CHRONICLE-FMT for logger binary-vanilla-chronicle-fmt
> 2014-08-28 12:12:29,268 ERROR Unable to locate appender
> PERF-BINARY-VANILLA-CHRONICLE for logger perf-binary-vanilla-chronicle
>
> The full code is on
>
> https://github.com/lburgazzoli/Chronicle-Logger/tree/HFT-CLOG-12/logger-log4j-2
>
> What's wrong with my setup?
>