You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Robert Breunung (JIRA)" <ji...@apache.org> on 2012/10/15 09:54:03 UTC

[jira] [Comment Edited] (LOG4J2-95) Adding a custom appender Appender

    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13476012#comment-13476012 ] 

Robert Breunung edited comment on LOG4J2-95 at 10/15/12 7:52 AM:
-----------------------------------------------------------------

I try a short introduction. As already mentioned, I use Eclipse 3.x. I'm not familiar with the changes made to plugin structure in Eclipse 4.

I think there are two interesting files for you. The first is the log configuration log4j2.xml.
The second is the Activator.java. There the code is found when starting and stopping a plugin. Here I tried to init the logger with some data before starting. In default there are only the parent  calls for start and stop. The other code is added. I pasted there multiple attempts so it may look little jammed.

My basic intention is, to register an appender to Log4J before start, so I can configure it via the log4j.xml. I tried it with naming the parent package of the appender, but I suppose, the term was meant different.
                
      was (Author: antrophos):
    I try a short introduction. As already mentioned, I use Eclipse 3.x. I'm not familiar with the changes mage to plugin structure in Eclipse 4.

I think there are two interesting files for you. The first is the log configuration log4j2.xml.
The second is the Activator.java. There the code is found when starting and stopping a plugin. Here I tried to init the logger with some data before starting. In default there are only the parent  calls for start and stop. The other code is added. I pasted there multiple attempts so it may look little jammed.

My basic intention is, to register an appender to Log4J before start, so I can configure it via the log4j.xml. I tried it with naming the parent package of the appender, but I suppose, the term was meant different.
                  
> Adding a custom appender Appender
> ---------------------------------
>
>                 Key: LOG4J2-95
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-95
>             Project: Log4j 2
>          Issue Type: Question
>          Components: Configurators
>    Affects Versions: 2.0-beta1
>         Environment: Windows 7 x64, Java 7 x86, Eclipse 3.8.1 x86, Eclipse RCP plugin application
>            Reporter: Robert Breunung
>              Labels: appender, extend
>         Attachments: Desktop.png, LogDemo.zip
>
>
> Hello,
> since two days I'm working with Log4j 2 . I try to migrate from Log4J. I'm using it in an Eclipse application. I put the necessary jars of the binary distribution into a basic plugin and a log4j2.xml into the root. This worked well so far. Now I tried to add a custom appender to log4j. The class is in the default source package of the Eclipse plugin. Annotations are set like in the homepage documentation.
> In the first try I tried to provide the package of the Appender via the log4j2.xml. I set the attribute package in the configuration element. It seemed to me, the attribute is completely ignored? At least the class from the given package was not loaded.
> In the second try I tried to provide the package via the static method '...log4j.core.config.plugin.PluginManager.addPackage'. I debugged the method to get a hint why it didn't work. It tried to transform my package 'com.application.logging' into a URI 'com/application/logging' and started to search with it somehow. It might have found them treating them as file, as the classes were lying in a subdirectory. But as there was no file scheme in the beginning of the URI, it searched a not existing jar.
> The XML parser of the configuration can't resolve the name of my appender in the end.
> Do you have an idea then I do anything wrong, or then there is an open issue? I can provide more details on request. Is there a programmatical way to register my appender to Log4J 2 before the Logger initialization?
> Sincerely
> Robert Breunung

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org