On Tue, Jan 26, 2016 at 1:06 PM, Apostolis Giannakidis <
ap.giannaki...@gmail.com> wrote:

> Actually, since this seems to be a useful feature, I would love to do the
> patch myself and contribute it to the project, if you don't mind.
>

Do you plan on implementing this for all Appenders?

Gary

>
> On Tue, Jan 26, 2016 at 8:56 PM, Ralph Goers <ralph.go...@dslextreme.com>
> wrote:
>
> > Actually, I kind of like the idea of adding a getAttributes() method to
> > the Appender interface. Then each concrete Appender would do:
> >
> > public void getAttributes() {
> >     Map<String, String> attributes = new HashMap<>();
> >     super.getAttributes(attributes):
> >     attributes.put(“myAttribute1”, “value1”);
> >     return Collections.unmodifiableMap(attributes);
> > }
> >
> >
> >
> > > On Jan 26, 2016, at 1:28 PM, Gary Gregory <garydgreg...@gmail.com>
> > wrote:
> > >
> > > How about adding getters for the fields
> > > in org.apache.logging.log4j.core.net.AbstractSocketManager?
> > >
> > > Gary
> > >
> > > On Tue, Jan 26, 2016 at 12:20 PM, Matt Sicker <boa...@gmail.com>
> wrote:
> > >
> > >> You could always use reflection to access it for now.
> > >>
> > >> On 26 January 2016 at 14:17, Apostolis Giannakidis <
> > >> ap.giannaki...@gmail.com
> > >>> wrote:
> > >>
> > >>> Thank you very much for the prompt reply Ralph.
> > >>>
> > >>> As far as I can see, the SyslogAppender class does not expose a way
> to
> > >>> access these attributes. So, if there is no other way of accessing
> > these
> > >>> attributes, then I am not able to retrieve the attributes that I want
> > >> from
> > >>> the existing SyslogAppender implementation. If I understand
> correctly,
> > >>> correct me if I am wrong, I might have to create my own that exposes
> > >> these
> > >>> attributes.
> > >>>
> > >>> Apos
> > >>>
> > >>> On Tue, Jan 26, 2016 at 8:03 PM, Ralph Goers <
> > ralph.go...@dslextreme.com
> > >>>
> > >>> wrote:
> > >>>
> > >>>> Not exactly. You can do:
> > >>>>
> > >>>> Appender appender =
> > >> ctx.getConfiguration().getAppender(“syslogAppender”);
> > >>>>
> > >>>> then you would have to do
> > >>>>
> > >>>> SyslogAppender syslogAppender = (SyslogAppender) appender;
> > >>>>
> > >>>> normally you would probably use instanceof to verify it is actually
> a
> > >>>> SyslogAppender.
> > >>>>
> > >>>> Once you have that you can call whatever methods the SyslogAppender
> > >>>> exposes for getting its attributes. They are not stored in a Map
> > >> however,
> > >>>> so you can’t just call a generic getAttribute method.
> > >>>>
> > >>>> Ralph
> > >>>>
> > >>>>
> > >>>>> On Jan 26, 2016, at 11:58 AM, Apostolis Giannakidis <
> > >>>> ap.giannaki...@gmail.com> wrote:
> > >>>>>
> > >>>>> Hello team,
> > >>>>>
> > >>>>> I have created a logger with an appender using the
> > >> ConfigurationBuilder
> > >>>> and
> > >>>>> the AppenderComponentBuilder.
> > >>>>>
> > >>>>> Let's say that this is how I create my appender:
> > >>>>>
> > >>>>> AppenderComponentBuilder appenderBuilder =
> > >>>>>               builder.newAppender( "syslogAppender", "Syslog" )
> > >>>>>               .addAttribute( "protocol", "TCP" )
> > >>>>>               .addAttribute( "host", "localhost" )
> > >>>>>               .addAttribute( "port", 514 )
> > >>>>>               .addAttribute( "facility", "LOCAL2" )
> > >>>>>               .addAttribute( "immediateFlush", true )
> > >>>>>               .addAttribute( "newLine", true );
> > >>>>>
> > >>>>> Then, after I finish creating the builder I use the
> > >>>>> Configurator.initialize( builder.build() ) to get the
> LoggerContext.
> > >>>>>
> > >>>>> Is there any way I can access the attributes of the appender
> through
> > >>> the
> > >>>>> LoggerContext?
> > >>>>>
> > >>>>> For example something like this:
> > >>>>>
> > >>>>> LoggerContext ctx = Configurator.initialize( builder.build() );
> > >>>>>
> > >>>>> String hostname =
> > >>>>>
> > >>>>
> > >>>
> > >>
> >
> ctx.getConfiguration()..getAppenders().get("syslogAppender").getAttribute("host");
> > >>>>>
> > >>>>> Thank you all very much for your help.
> > >>>>>
> > >>>>> Apostolis
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> ---------------------------------------------------------------------
> > >>>> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > >>>> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> > >>>>
> > >>>>
> > >>>
> > >>
> > >>
> > >>
> > >> --
> > >> Matt Sicker <boa...@gmail.com>
> > >>
> > >
> > >
> > >
> > > --
> > > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> > > Java Persistence with Hibernate, Second Edition
> > > <http://www.manning.com/bauer3/>
> > > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > > Spring Batch in Action <http://www.manning.com/templier/>
> > > Blog: http://garygregory.wordpress.com
> > > Home: http://garygregory.com/
> > > Tweet! http://twitter.com/GaryGregory
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
> >
>



-- 
E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Reply via email to