You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flume.apache.org by Ralph Goers <ra...@dslextreme.com> on 2011/08/15 16:04:37 UTC

Log4J V2 Appender

I have been working on developing V2 of Log4j. As part of that I wrote an appender for Flume that does a bit more than the Log4j appender built into Flume. I'd appreciate it if you guys could look at it and let me know of any problems you find. The source is located at https://svn.apache.org/repos/asf/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/flume/

Thanks,
Ralph

Re: Log4J V2 Appender

Posted by "ralph.goers @dslextreme.com" <ra...@dslextreme.com>.
Thanks. I guess I'll have to give a bit of an overview since I've written
absolutely no documentation yet.

In 2.0 I've made the configurable elements "plugins". You define it with the
annotations and then they are available to be used in the XML configuration
without having to declare class names. The plugins are wired together by how
they appear in the configuration. This makes it pretty easy to add a new
Appender and then define a new configuration element (such as the Agent
object).

Each plugin declares a PluginFactory method that is called to create the
object. Because of this, most plugins are immutable and thus thread-safe.

Everything in 2.0 locks at the lowest level possible to avoid the deadlocks
that can occur in Log4j 1.x. Everything is synchronous, however there is no
reason an AsynchronousAppender can't be created to wrap any other appender.
But that would also mean that any errors or exceptions that occur would most
likely be lost to the application. In the use case I'm solving for (audit
logging) I wouldn't want the appender to be asynchronous until it is
accepted by the agent. It doesn't need to make it to the repository if the
agent can guarantee delivery.

Although not always required, every appender I've created uses a Manager.
This allows multiple configurations (for example, multiple web applications
in an app server) to share the same output stream and/or have a single place
where file rollover occurs - assuming Log4J V2 is deployed to a class loader
common to all the web applications.

AbstractManager provides the release method. It obtains the lock on the
manager so that its use count can be safely decremented and then removed
from the map of managers if appropriate. At that point releaseSub is called
to perform any cleanup that should occur when the manager is released. It is
empty in FlumeAvroManager only because I'm not aware of any work that should
be performed there. If it is missing something that should be done please
let me know.

If you need more information feel free to ask.

Ralph



On Tue, Aug 16, 2011 at 1:58 PM, Jonathan Hsieh <jo...@cloudera.com> wrote:

> Hey Ralph,
>
> Cool!  I'll took a quick look and need will take a deeper look (looking up
> the log4j interfaces/annotations etc) tonight/tomorrow .
>
> To clarify, this would be some sort of plugin for the log4j/logging
> project?
>
> First look questions --
> - why is releaseSub() empty?
> - what are the proper semantics for blocking with an appender?  (are they
> assumed to be asynchronous or synchronus? are these essentially
> log4j/logging options?)
>
> Thanks,
> Jon.
>
> On Mon, Aug 15, 2011 at 7:04 AM, Ralph Goers <ralph.goers@dslextreme.com
> >wrote:
>
> > I have been working on developing V2 of Log4j. As part of that I wrote an
> > appender for Flume that does a bit more than the Log4j appender built
> into
> > Flume. I'd appreciate it if you guys could look at it and let me know of
> any
> > problems you find. The source is located at
> >
> https://svn.apache.org/repos/asf/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/flume/
> >
> > Thanks,
> > Ralph
>
>
>
>
> --
> // Jonathan Hsieh (shay)
> // Software Engineer, Cloudera
> // jon@cloudera.com
>

Re: Log4J V2 Appender

Posted by Jonathan Hsieh <jo...@cloudera.com>.
Hey Ralph,

Cool!  I'll took a quick look and need will take a deeper look (looking up
the log4j interfaces/annotations etc) tonight/tomorrow .

To clarify, this would be some sort of plugin for the log4j/logging
project?

First look questions --
- why is releaseSub() empty?
- what are the proper semantics for blocking with an appender?  (are they
assumed to be asynchronous or synchronus? are these essentially
log4j/logging options?)

Thanks,
Jon.

On Mon, Aug 15, 2011 at 7:04 AM, Ralph Goers <ra...@dslextreme.com>wrote:

> I have been working on developing V2 of Log4j. As part of that I wrote an
> appender for Flume that does a bit more than the Log4j appender built into
> Flume. I'd appreciate it if you guys could look at it and let me know of any
> problems you find. The source is located at
> https://svn.apache.org/repos/asf/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/flume/
>
> Thanks,
> Ralph




-- 
// Jonathan Hsieh (shay)
// Software Engineer, Cloudera
// jon@cloudera.com