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/10 16:11:04 UTC

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

Robert Breunung created LOG4J2-95:
-------------------------------------

             Summary: 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


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


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

Posted by "Aaron Shepherd (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13484160#comment-13484160 ] 

Aaron Shepherd commented on LOG4J2-95:
--------------------------------------

Sorry for the confusion.  I created a user library in Eclipse for all of the log4j2 jars, source code and javadocs.  I tried including the appender jar in that same Eclipse library, but the physical location of the jar was different from that of the log4j2 jars.  After seeing your post, I have moved the jar to the same directory as all of the log4j2 jars and I still get the class not found error.  Also, I have noticed that after removing the appender from my project, packaging it in a jar, and adding that jar to my build path, my HappyTest java execution is no longer finding the appender.  I specified for the configuration to look in my "com.log4j" package, but it appears to only be looking for that package within the project itself.
                
> 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, happyTestProject.rftjdtr, 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


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

Posted by "Robert Breunung (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13476117#comment-13476117 ] 

Robert Breunung commented on LOG4J2-95:
---------------------------------------

A colleague of mine said to me that would probably be no help for you to understand my eclipse project. Instead you may create a simple example project, where you add a new implemented Appender during runtime of the example. This can be before first initialization of a logger. Can this Appender be referenced by the log4j2.xml? Can I alternatively modify the configuration, so the appender will be propagated to all logger?
                
> 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486635#comment-13486635 ] 

Ralph Goers commented on LOG4J2-95:
-----------------------------------

I was able to create an Eclipse Plugin project and duplicate the issue.  When running under the debugger I see that the protocol returned on the URL is bundleresource. I guess just like I had to add support for vfszip for JBoss I will have to add something to support this.  Now I just have to figure out what that is.
                
> 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, happyTestProject.rftjdtr, 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475734#comment-13475734 ] 

Ralph Goers commented on LOG4J2-95:
-----------------------------------

After screwing around for a few hours I have no idea if I am even close to getting your test to work or fail properly. At the moment my output looks like

eclipse.buildId=unknown
java.version=1.7.0_05
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments:  -application LogDemo.application
Command-line arguments:  -application LogDemo.application -data /Users/rgoers/eclipse/workspace/../runtime-LogDemo.application -dev file:/Users/rgoers/eclipse/workspace/.metadata/.plugins/org.eclipse.pde.core/LogDemo.application/dev.properties -os macosx -ws cocoa -arch x86_64 -consoleLog

!ENTRY org.eclipse.equinox.ds 4 0 2012-10-13 17:03:24.478
!MESSAGE [SCR] Exception while activating instance org.eclipse.e4.ui.css.swt.internal.theme.ThemeEngineManager@4ca21d88 of component org.eclipse.e4.ui.css.swt.theme  
!STACK 0
java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Display
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
	at java.lang.Class.getDeclaredMethods(Class.java:1808)
	at org.eclipse.equinox.internal.ds.model.ServiceComponent.getMethod(ServiceComponent.java:126)
	at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:213)
	at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
	at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
	at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
	at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
	at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
	at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
	at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
	at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
	at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
	at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Display
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
	... 15 more

I've not figured out what I have to do to make Eclipse happy.
                
> 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: 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


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

Posted by "Aaron Shepherd (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483439#comment-13483439 ] 

Aaron Shepherd edited comment on LOG4J2-95 at 10/24/12 6:07 PM:
----------------------------------------------------------------

I am having a similar issue with using a custom appender with Rational Functional Tester (RFT) scripts.  RFT is essentially plugin for Eclipse which uses java code to drive automation testing of web interfaces, however it specifies its own "main" method and performs its own class loading.  To debug my issue I created a basic project which contained the following elements:

- A log4j2.xml configuration file located in the root of the project which references my custom appender and specifies its package
- A custom appender, HappyAppender, annotated as instructed, in the package com.log4j
- A standard java file with a main method in the package com.log4j
- A standard RFT script file with a main method in the package com.log4j

Both the java file and the RFT script have the exact same code in their main methods.  When executed with the configuration's "verbose" option set to "true", the output of the java execution indicates that it scanned the com.log4j package and the appender class was found:

2012-10-24 13:59:38,283 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4jRftTest/com/log4j] matching criteria: annotated with @Plugin
2012-10-24 13:59:38,283 DEBUG Checking to see if class com.log4j.HappyAppender matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,288 DEBUG Checking to see if class com.log4j.HappyScript matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,308 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,308 DEBUG Generated plugins in 0.026926816 seconds

However, the verbose output of the RFT script execution does not contain the same message and instead displays an error that the appender class could not be found:

2012-10-24 13:33:46,887 DEBUG Generated plugins in 0.000241231 seconds
2012-10-24 13:33:46,892 ERROR Error processing element Happy: CLASS_NOT_FOUND

Being that these files are all in the same package of the same project, executing the same code and referencing the same configuration file, the only difference I can think of as to why one execution could find the appender and the other could not is that RFT does its own class loading.  I verified that the class loader returned by HappyScript.class.getClassLoader() is different from the one returned by LogManager.class.getClassLoader(), and that the class loader returned by HappyScript.class.getClassLoader() is the same as the one returned by LogManager.class.getClassLoader().

Am on the right track with this, or should the loader difference not matter?

                
      was (Author: atshephe):
    I am having a similar issue with using a custom appender with Rational Functional Tester (RFT) scripts.  RFT is essentially plugin for Eclipse which uses java code to drive automation testing of web interfaces, however it specifies its own "main" method and performs its own class loading.  To debug my issue I created a basic project which was contained the following elements:

- A log4j2.xml configuration file located in the root of the project which references my custom appender and specifies its package
- A custom appender, HappyAppender, annotated as instructed, in the package com.log4j
- A standard java file with a main method in the package com.log4j
- A standard RFT script file with a main method in the package com.log4j

Both the java file and the RFT script have the exact same code in their main methods.  When executed with the configuration's "verbose" option set to "true", the output of the java execution indicates that it scanned the com.log4j package and the appender class was found:

2012-10-24 13:59:38,283 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4jRftTest/com/log4j] matching criteria: annotated with @Plugin
2012-10-24 13:59:38,283 DEBUG Checking to see if class com.log4j.HappyAppender matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,288 DEBUG Checking to see if class com.log4j.HappyScript matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,308 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,308 DEBUG Generated plugins in 0.026926816 seconds

However, the verbose output of the RFT script execution does not contain the same message and instead displays an error that the appender class could not be found:

2012-10-24 13:33:46,887 DEBUG Generated plugins in 0.000241231 seconds
2012-10-24 13:33:46,892 ERROR Error processing element Happy: CLASS_NOT_FOUND

Being that these files are all in the same package of the same project, executing the same code and referencing the same configuration file, the only difference I can think of as to why one execution could find the appender and the other could not is that RFT does its own class loading.  I verified that the class loader returned by HappyScript.class.getClassLoader() is different from the one returned by LogManager.class.getClassLoader(), and that the class loader returned by HappyScript.class.getClassLoader() is the same as the one returned by LogManager.class.getClassLoader().

Am on the right track with this, or should the loader difference not matter?

                  
> 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13490144#comment-13490144 ] 

Ralph Goers commented on LOG4J2-95:
-----------------------------------

I spent most of my day trying to create a unit test for this but had no luck.  If you could validate the fix I would appreciate it.
                
> 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, happyTestProject.rftjdtr, 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


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

Posted by "Aaron Shepherd (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483524#comment-13483524 ] 

Aaron Shepherd commented on LOG4J2-95:
--------------------------------------

Honestly, my knowledge of class loading is rather limited so you might start losing me with some of this stuff.  That said, I'm not sure that there is a direct parent/child relationship between the loaders.  I did a quick loop through the loaders for my test script and for LogManager (if you have a better suggestion for getting the log4j loader let me know), and they don't meet up at all:

Script loader hierarchy:

class com.rational.test.ft.util.FtClassLoader
class com.rational.test.ft.util.FtClassLoader
class org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader
class org.eclipse.osgi.baseadaptor.BaseAdaptor$1

Log4j loader hierarchy:

class sun.misc.Launcher$AppClassLoader
class sun.misc.Launcher$ExtClassLoader

Loader.getClassLoader() returned a similar hierachy as LogManager, with an additional ContextFinder class as the initial loader.

At this point some background info on RFT might be helpful.  As I stated before, it is a plugin for Eclipse, so project setup is very similar to a standard Java project in Eclipse.  I have added the log4j jars to the build path of the project as a user library.  Originally, the HappyAppender was simply a class within the project itself, but I have since exported HappyAppender to a jar tried both of the following:

- Added the jar directly to the build path of the project
- Added the jar to the log4j user library

Both of these failed with the same error as having the appender directly in the project.  Any additional instruction for things I can do would be appreciated, though I'm not sure at this point I'd know how to implement them immediately.

Also, if you feel that this issue is dissimilar enough from Robert's original issue please let me know.  I posted here since RFT is a plugin to Eclipse and I was having a similar issue with getting a custom appender to work within the context of that plugin.
                
> 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, happyTestProject.rftjdtr, 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ralph Goers updated LOG4J2-95:
------------------------------

    Fix Version/s: 2.0-beta3
    
> 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
>             Fix For: 2.0-beta3
>
>         Attachments: Desktop.png, happyTestProject.rftjdtr, 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


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

Posted by "Robert Breunung (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Breunung updated LOG4J2-95:
----------------------------------

    Attachment: Desktop.png

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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483453#comment-13483453 ] 

Ralph Goers commented on LOG4J2-95:
-----------------------------------

Yes, the ClassLoader could matter. The PluginManager uses Loader.getClassLoader() to locate the ClassLoader it believes is correct to locate classes. Would it be possible to package the custom appender in a jar that can be loaded in the same ClassLoader as log4j?
                
> 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


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

Posted by "Aaron Shepherd (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483439#comment-13483439 ] 

Aaron Shepherd commented on LOG4J2-95:
--------------------------------------

I am having a similar issue with using a custom appender with Rational Functional Tester (RFT) scripts.  RFT is essentially plugin for Eclipse which uses java code to drive automation testing of web interfaces, however it specifies its own "main" method and performs its own class loading.  To debug my issue I created a basic project which was contained the following elements:

- A log4j2.xml configuration file located in the root of the project which references my custom appender and specifies its package
- A custom appender, HappyAppender, annotated as instructed, in the package com.log4j
- A standard java file with a main method in the package com.log4j
- A standard RFT script file with a main method in the package com.log4j

Both the java file and the RFT script have the exact same code in their main methods.  When executed with the configuration's "verbose" option set to "true", the output of the java execution indicates that it scanned the com.log4j package and the appender class was found:

2012-10-24 13:59:38,283 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4jRftTest/com/log4j] matching criteria: annotated with @Plugin
2012-10-24 13:59:38,283 DEBUG Checking to see if class com.log4j.HappyAppender matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,288 DEBUG Checking to see if class com.log4j.HappyScript matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,308 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,308 DEBUG Generated plugins in 0.026926816 seconds

However, the verbose output of the RFT script execution does not contain the same message and instead displays an error that the appender class could not be found:

2012-10-24 13:33:46,887 DEBUG Generated plugins in 0.000241231 seconds
2012-10-24 13:33:46,892 ERROR Error processing element Happy: CLASS_NOT_FOUND

Being that these files are all in the same package of the same project, executing the same code and referencing the same configuration file, the only difference I can think of as to why one execution could find the appender and the other could not is that RFT does its own class loading.  I verified that the class loader returned by HappyScript.class.getClassLoader() is different from the one returned by LogManager.class.getClassLoader(), and that the class loader returned by HappyScript.class.getClassLoader() is the same as the one returned by LogManager.class.getClassLoader().

Am on the right track with this, or should the loader difference not matter?

                
> 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


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

Posted by "Robert Breunung (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475806#comment-13475806 ] 

Robert Breunung commented on LOG4J2-95:
---------------------------------------

Hello,

Thanks for the answer.

The project I provided is not just a simple Java project. It's a plugin as used in an Eclipse RCP Application. So it has dependencies on the Eclipse3 platform including OSGI and SWT.

I'd recommend to use the latest Eclipse 3.8.1 SDK for viewing.

Else I'could need a step by step instruction, how to add custom appenders during runtime. This was, what I tried to do.
                
> 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: 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


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

Posted by "Robert Breunung (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Breunung updated LOG4J2-95:
----------------------------------

    Attachment: LogDemo.zip

A minimal demo of a eclipse plugin application using log4j 2.
                
> 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: 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


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

Posted by "Robert Breunung (JIRA)" <ji...@apache.org>.
    [ 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


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

Posted by "Robert Breunung (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13476031#comment-13476031 ] 

Robert Breunung commented on LOG4J2-95:
---------------------------------------

The added screenshot should point you out the most important things.As you already executed the application, you know how to import a project from a directory. Eclipse plugin configuration is done in plugin.xml. OSGI configuration is done in manifest.mf. The view in the center background of the screenshot is a graphical editor to that files. Here are the log4j2 dependencies described.
                
> 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


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

Posted by "Aaron Shepherd (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483483#comment-13483483 ] 

Aaron Shepherd edited comment on LOG4J2-95 at 10/24/12 7:07 PM:
----------------------------------------------------------------

I have attached the exported RFT project items used for my custom appender test.

If you have access to RFT, you can import the project using File -> Import -> Functional Test Project Items.
If you do not have access to RFT, the attached file is a zip archive with a custom extension.  You can open the archive and look at the java files contained within to see the script and appender files.

Note that this test was done using log4j2-b2 and RFT 8.2.1, but a newer version of RFT should be fine.
                
      was (Author: atshephe):
    RFT project items for a custom appender test
                  
> 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, happyTestProject.rftjdtr, 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475923#comment-13475923 ] 

Ralph Goers commented on LOG4J2-95:
-----------------------------------

It seems I managed to get "Run as Eclipse Application" to work.  However, it opened up another Eclipse window and now I don't know where to go from there to test this.
                
> 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: 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475436#comment-13475436 ] 

Ralph Goers commented on LOG4J2-95:
-----------------------------------

I apologize but this may take a while as this appears to be something targeted at Eclipse. I use IntelliJ so I'm going to have to figure out what to do.
                
> 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: 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


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

Posted by "Aaron Shepherd (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483439#comment-13483439 ] 

Aaron Shepherd edited comment on LOG4J2-95 at 10/24/12 6:09 PM:
----------------------------------------------------------------

I am having a similar issue with using a custom appender with Rational Functional Tester (RFT) scripts.  RFT is essentially plugin for Eclipse which uses java code to drive automation testing of web interfaces, however it specifies its own "main" method and performs its own class loading.  To debug my issue I created a basic project which contained the following elements:

- A log4j2.xml configuration file located in the root of the project which references my custom appender and specifies its package
- A custom appender, HappyAppender, annotated as instructed in the package com.log4j
- A standard java file, HappyTest, with a main method in the package com.log4j
- A standard RFT script file, HappyScript, with a main method in the package com.log4j

Both the java file and the RFT script have the exact same code in their main methods.  When executed with the configuration's "verbose" option set to "true", the output of the java execution indicates that it scanned the com.log4j package and the appender class was found:

2012-10-24 13:59:38,283 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4jRftTest/com/log4j] matching criteria: annotated with @Plugin
2012-10-24 13:59:38,283 DEBUG Checking to see if class com.log4j.HappyAppender matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,288 DEBUG Checking to see if class com.log4j.HappyScript matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,308 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,308 DEBUG Generated plugins in 0.026926816 seconds

However, the verbose output of the RFT script execution does not contain the same message and instead displays an error that the appender class could not be found:

2012-10-24 13:33:46,887 DEBUG Generated plugins in 0.000241231 seconds
2012-10-24 13:33:46,892 ERROR Error processing element Happy: CLASS_NOT_FOUND

Being that these files are all in the same package of the same project, executing the same code and referencing the same configuration file, the only difference I can think of as to why one execution could find the appender and the other could not is that RFT does its own class loading.  I verified that the class loader returned by HappyScript.class.getClassLoader() is different from the one returned by LogManager.class.getClassLoader(), and that the class loader returned by HappyScript.class.getClassLoader() is the same as the one returned by LogManager.class.getClassLoader().

Am on the right track with this, or should the loader difference not matter?

                
      was (Author: atshephe):
    I am having a similar issue with using a custom appender with Rational Functional Tester (RFT) scripts.  RFT is essentially plugin for Eclipse which uses java code to drive automation testing of web interfaces, however it specifies its own "main" method and performs its own class loading.  To debug my issue I created a basic project which contained the following elements:

- A log4j2.xml configuration file located in the root of the project which references my custom appender and specifies its package
- A custom appender, HappyAppender, annotated as instructed, in the package com.log4j
- A standard java file with a main method in the package com.log4j
- A standard RFT script file with a main method in the package com.log4j

Both the java file and the RFT script have the exact same code in their main methods.  When executed with the configuration's "verbose" option set to "true", the output of the java execution indicates that it scanned the com.log4j package and the appender class was found:

2012-10-24 13:59:38,283 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4jRftTest/com/log4j] matching criteria: annotated with @Plugin
2012-10-24 13:59:38,283 DEBUG Checking to see if class com.log4j.HappyAppender matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,288 DEBUG Checking to see if class com.log4j.HappyScript matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,308 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin]
2012-10-24 13:59:38,308 DEBUG Generated plugins in 0.026926816 seconds

However, the verbose output of the RFT script execution does not contain the same message and instead displays an error that the appender class could not be found:

2012-10-24 13:33:46,887 DEBUG Generated plugins in 0.000241231 seconds
2012-10-24 13:33:46,892 ERROR Error processing element Happy: CLASS_NOT_FOUND

Being that these files are all in the same package of the same project, executing the same code and referencing the same configuration file, the only difference I can think of as to why one execution could find the appender and the other could not is that RFT does its own class loading.  I verified that the class loader returned by HappyScript.class.getClassLoader() is different from the one returned by LogManager.class.getClassLoader(), and that the class loader returned by HappyScript.class.getClassLoader() is the same as the one returned by LogManager.class.getClassLoader().

Am on the right track with this, or should the loader difference not matter?

                  
> 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483571#comment-13483571 ] 

Ralph Goers commented on LOG4J2-95:
-----------------------------------

First, I suspect that your issue is very similar to the original issue, so your offering to help is much appreciated.

I'm not sure by what you said if the jar containing your custom appender was placed into the same location where the log4j 2 jars were placed.  Is that what you meant by the log4j user library?  If you did then I don't understand why that wouldn't solve the problem since you would be using the same class loader as Log4j uses to load its own classes.
                
> 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, happyTestProject.rftjdtr, 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13487184#comment-13487184 ] 

Ralph Goers commented on LOG4J2-95:
-----------------------------------

I have committed a fix and tested it in both Indigo and Juno. However, I'm not going to mark this as resolved quite yet as I would like to create a unit test against this.
                
> 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, happyTestProject.rftjdtr, 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


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

Posted by "Aaron Shepherd (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aaron Shepherd updated LOG4J2-95:
---------------------------------

    Attachment: happyTestProject.rftjdtr

RFT project items for a custom appender test
                
> 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, happyTestProject.rftjdtr, 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483499#comment-13483499 ] 

Ralph Goers commented on LOG4J2-95:
-----------------------------------

I'll have to download RFT but if I understand correctly the class path organization has the Log4j classes in a parent class loader and the log4j plugin classes in a child class loader.  If I were to extrapolate this to an environment such as Tomcat this would be like having the Log4j files in Tomcat's lib directory and the log4j plugins in the web app. Hopefully you would understand why it would be a bad idea for Log4j to be loading classes from a child class loader in that case.
                
> 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, happyTestProject.rftjdtr, 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13473272#comment-13473272 ] 

Ralph Goers commented on LOG4J2-95:
-----------------------------------

Would it be possible for you to attach what you have as a zipped project so that I can take a look at it?
                
> 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
>
> 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475852#comment-13475852 ] 

Ralph Goers commented on LOG4J2-95:
-----------------------------------

I downloaded Eclipse for RCP and I am still seeing the same error. Under the Plugins tab next to Package Explorer I see org.eclipse.swt.cocoa.macosx.x86_64 and org.eclipse.swt but neither of these show up in the list of plugins when I try to add them as dependencies to your project. In that list I only see org.eclipse.swt.cocoa.macosx.x86_64.source, which doesn't resolve the problem.

So basically, I think I need instructions on exactly how to install Eclipse to get the project to work on my Mac.
                
> 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: 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483453#comment-13483453 ] 

Ralph Goers edited comment on LOG4J2-95 at 10/24/12 6:38 PM:
-------------------------------------------------------------

Yes, the ClassLoader could matter. The PluginManager uses Loader.getClassLoader() to locate the ClassLoader it believes is correct to locate classes. Would it be possible to package the custom appender in a jar that can be loaded in the same ClassLoader as log4j?

Could you package your happy project along with some instructions so that I can test it myself and see if something can be done to make this more convenient?
                
      was (Author: ralph.goers@dslextreme.com):
    Yes, the ClassLoader could matter. The PluginManager uses Loader.getClassLoader() to locate the ClassLoader it believes is correct to locate classes. Would it be possible to package the custom appender in a jar that can be loaded in the same ClassLoader as log4j?
                  
> 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ralph Goers resolved LOG4J2-95.
-------------------------------

    Resolution: Fixed
      Assignee: Ralph Goers

Please verify this and then close it.
                
> 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
>            Assignee: Ralph Goers
>              Labels: appender, extend
>             Fix For: 2.0-beta3
>
>         Attachments: Desktop.png, happyTestProject.rftjdtr, 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13483499#comment-13483499 ] 

Ralph Goers edited comment on LOG4J2-95 at 10/24/12 7:28 PM:
-------------------------------------------------------------

I'll have to download RFT but if I understand correctly the class path organization has the Log4j classes in a parent class loader and the log4j plugin classes in a child class loader.  If I were to extrapolate this to an environment such as Tomcat this would be like having the Log4j files in Tomcat's lib directory and the log4j plugins in the web app. Hopefully you would understand why it could be a bad idea for Log4j to be loading classes from a child class loader if the configuration is also at the Tomcat level. However, if the configuration is in the Web app it would make sense for the plugins to be located. 

So even without getting RFT you may have given me a few ways to try to emulate this.
                
      was (Author: ralph.goers@dslextreme.com):
    I'll have to download RFT but if I understand correctly the class path organization has the Log4j classes in a parent class loader and the log4j plugin classes in a child class loader.  If I were to extrapolate this to an environment such as Tomcat this would be like having the Log4j files in Tomcat's lib directory and the log4j plugins in the web app. Hopefully you would understand why it would be a bad idea for Log4j to be loading classes from a child class loader in that case.
                  
> 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, happyTestProject.rftjdtr, 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


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

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475848#comment-13475848 ] 

Ralph Goers commented on LOG4J2-95:
-----------------------------------

Yes, I know it isn't a typical Java project. The latest thing I tried was Eclipse Classic 4.2.1 for Mac OS/X 64 bit which gave me the stack trace above.  I first downloaded Eclipse IDE for Java developers and when that didn't work I downloaded Eclipse Classic 4.2..1 for Mac OS/X 32 bit and that also failed.  From your description I am now wondering if I need Eclipse for RCP and RAP developers Mac OS/X 64 bit.  .  
                
> 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: 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


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

Posted by "Robert Breunung (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4J2-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13473402#comment-13473402 ] 

Robert Breunung commented on LOG4J2-95:
---------------------------------------

Hello,

I added the wished demo of my application. I reduced it to a minimum of a default hello world and some basic function of my appender. I hope this helps.
                
> 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: 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