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 dxande6 <de...@gmail.com> on 2014/07/14 19:54:15 UTC
Extending Appenders
I've tried extending the appenders with the following code and keep getting
errors:
@Plugin(name = "Stub", category = "Core", elementType = "appender",
printObject = true)
2.public final class StubAppender extends OutputStreamAppender {
3.
4. private StubAppender(String name, Layout layout, Filter filter,
StubManager manager,
5. boolean ignoreExceptions) {
6. }
7.
8. @PluginFactory
9. public static StubAppender createAppender(@PluginAttribute("name")
String name,
10.
@PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
11. @PluginElement("Layout")
Layout layout,
12. @PluginElement("Filters")
Filter filter) {
13.
14. if (name == null) {
15. LOGGER.error("No name provided for StubAppender");
16. return null;
17. }
18.
19. StubManager manager = StubManager.getStubManager(name);
20. if (manager == null) {
21. return null;
22. }
23. if (layout == null) {
24. layout = PatternLayout.createDefaultLayout();
25. }
26. return new StubAppender(name, layout, filter, manager,
ignoreExceptions);
27. }
28.}
I got this example from here:
http://logging.apache.org/log4j/2.x/manual/extending.html
It tells me that OutputStreamAppender and LOGGER is not defined.
I'm a little confused on what to do with this issue.
Additonally, I'm not familiar with StubManager and it's implementation, any
insight is GREATLY appreciated.
Thank you,
-Dean
--
View this message in context: http://apache-logging.6191.n7.nabble.com/Extending-Appenders-tp49160.html
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Extending Appenders
Posted by Ralph Goers <ra...@dslextreme.com>.
Did you import OutputStreamAppender, etc. and are log4j-api and log4j-core in the compile classpath?
The “StubManager” is where all the real i/o happens and will typically persist across a reconfiguration if the Appender is still being used. For an OutputStreamAppender it would probably extend OutputStreamManager.
You probably want to look at something like ConsoleAppender to see how a real Appender works.
Ralph
On Jul 14, 2014, at 10:54 AM, dxande6 <de...@gmail.com> wrote:
> I've tried extending the appenders with the following code and keep getting
> errors:
>
> @Plugin(name = "Stub", category = "Core", elementType = "appender",
> printObject = true)
> 2.public final class StubAppender extends OutputStreamAppender {
> 3.
> 4. private StubAppender(String name, Layout layout, Filter filter,
> StubManager manager,
> 5. boolean ignoreExceptions) {
> 6. }
> 7.
> 8. @PluginFactory
> 9. public static StubAppender createAppender(@PluginAttribute("name")
> String name,
> 10.
> @PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
> 11. @PluginElement("Layout")
> Layout layout,
> 12. @PluginElement("Filters")
> Filter filter) {
> 13.
> 14. if (name == null) {
> 15. LOGGER.error("No name provided for StubAppender");
> 16. return null;
> 17. }
> 18.
> 19. StubManager manager = StubManager.getStubManager(name);
> 20. if (manager == null) {
> 21. return null;
> 22. }
> 23. if (layout == null) {
> 24. layout = PatternLayout.createDefaultLayout();
> 25. }
> 26. return new StubAppender(name, layout, filter, manager,
> ignoreExceptions);
> 27. }
> 28.}
>
> I got this example from here:
> http://logging.apache.org/log4j/2.x/manual/extending.html
>
> It tells me that OutputStreamAppender and LOGGER is not defined.
> I'm a little confused on what to do with this issue.
>
> Additonally, I'm not familiar with StubManager and it's implementation, any
> insight is GREATLY appreciated.
>
> Thank you,
>
> -Dean
>
>
>
>
> --
> View this message in context: http://apache-logging.6191.n7.nabble.com/Extending-Appenders-tp49160.html
> Sent from the Log4j - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org