Details

    • Type: Question Question
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta1
    • Fix Version/s: 2.0-beta3
    • Component/s: Configurators
    • Labels:
    • Environment:

      Windows 7 x64, Java 7 x86, Eclipse 3.8.1 x86, Eclipse RCP plugin application

      Description

      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

      1. happyTestProject.rftjdtr
        4 kB
        Aaron Shepherd
      2. Desktop.png
        453 kB
        Robert Breunung
      3. LogDemo.zip
        2.39 MB
        Robert Breunung

        Activity

        Hide
        Ralph Goers added a comment -

        Would it be possible for you to attach what you have as a zipped project so that I can take a look at it?

        Show
        Ralph Goers added a comment - Would it be possible for you to attach what you have as a zipped project so that I can take a look at it?
        Hide
        Robert Breunung added a comment -

        A minimal demo of a eclipse plugin application using log4j 2.

        Show
        Robert Breunung added a comment - A minimal demo of a eclipse plugin application using log4j 2.
        Hide
        Robert Breunung added a comment -

        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.

        Show
        Robert Breunung added a comment - 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.
        Hide
        Ralph Goers added a comment -

        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.

        Show
        Ralph Goers added a comment - 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.
        Hide
        Ralph Goers added a comment -

        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.

        Show
        Ralph Goers added a comment - 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.
        Hide
        Robert Breunung added a comment -

        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.

        Show
        Robert Breunung added a comment - 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.
        Hide
        Ralph Goers added a comment -

        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. .

        Show
        Ralph Goers added a comment - 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. .
        Hide
        Ralph Goers added a comment -

        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.

        Show
        Ralph Goers added a comment - 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.
        Hide
        Ralph Goers added a comment -

        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.

        Show
        Ralph Goers added a comment - 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.
        Hide
        Robert Breunung added a comment - - edited

        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.

        Show
        Robert Breunung added a comment - - edited 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.
        Hide
        Robert Breunung added a comment -

        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.

        Show
        Robert Breunung added a comment - 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.
        Hide
        Robert Breunung added a comment -

        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?

        Show
        Robert Breunung added a comment - 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?
        Hide
        Aaron Shepherd added a comment - - edited

        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?

        Show
        Aaron Shepherd added a comment - - edited 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?
        Hide
        Ralph Goers added a comment - - edited

        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?

        Show
        Ralph Goers added a comment - - edited 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?
        Hide
        Aaron Shepherd added a comment - - edited

        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.

        Show
        Aaron Shepherd added a comment - - edited 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.
        Hide
        Ralph Goers added a comment - - edited

        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.

        Show
        Ralph Goers added a comment - - edited 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.
        Hide
        Aaron Shepherd added a comment -

        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.

        Show
        Aaron Shepherd added a comment - 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.
        Hide
        Ralph Goers added a comment -

        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.

        Show
        Ralph Goers added a comment - 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.
        Hide
        Aaron Shepherd added a comment -

        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.

        Show
        Aaron Shepherd added a comment - 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.
        Hide
        Ralph Goers added a comment -

        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.

        Show
        Ralph Goers added a comment - 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.
        Hide
        Ralph Goers added a comment -

        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.

        Show
        Ralph Goers added a comment - 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.
        Hide
        Ralph Goers added a comment -

        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.

        Show
        Ralph Goers added a comment - 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.
        Hide
        Ralph Goers added a comment -

        Please verify this and then close it.

        Show
        Ralph Goers added a comment - Please verify this and then close it.
        Hide
        Aaron Shepherd added a comment -

        Hi Ralph, sorry I have not been able to get to verifying this (assuming you were talking to me as well). Where can I get the latest beta version for verification? Beta2 is the latest release that I see and I don't see any attachments for me to download.

        Show
        Aaron Shepherd added a comment - Hi Ralph, sorry I have not been able to get to verifying this (assuming you were talking to me as well). Where can I get the latest beta version for verification? Beta2 is the latest release that I see and I don't see any attachments for me to download.
        Hide
        Ralph Goers added a comment -

        The latest release is beta3 and is available at http://logging.apache.org/log4j/2.x/download.html.

        Show
        Ralph Goers added a comment - The latest release is beta3 and is available at http://logging.apache.org/log4j/2.x/download.html .
        Hide
        Aaron Shepherd added a comment -

        Ha, I feel dumb. I clicked on the fix version link above rather than going to the main site. Thanks.

        Show
        Aaron Shepherd added a comment - Ha, I feel dumb. I clicked on the fix version link above rather than going to the main site. Thanks.
        Hide
        Robert Breunung added a comment -

        Letting some time pass and rereading the documentation again I understand most of the mistakes I made.

        As Log4J2 precaches all appenders it will not read another appender simply because I implemented it according to the tutorial. Is it already somewhere documented, how to add appenders? I'd rather not create a custom Maven plugin but just implement it inside my Eclipse plugin.

        In org.apache.logging.log4j.core.config.plugins.PluginManager.java talk is about a package name to be scanned, prior to plugins collected .... Does this mean the same caching mechanism as mentioned before? If yes, is there any use for me calling this method?

        Show
        Robert Breunung added a comment - Letting some time pass and rereading the documentation again I understand most of the mistakes I made. As Log4J2 precaches all appenders it will not read another appender simply because I implemented it according to the tutorial. Is it already somewhere documented, how to add appenders? I'd rather not create a custom Maven plugin but just implement it inside my Eclipse plugin. In org.apache.logging.log4j.core.config.plugins.PluginManager.java talk is about a package name to be scanned, prior to plugins collected .... Does this mean the same caching mechanism as mentioned before? If yes, is there any use for me calling this method?
        Hide
        Aaron Shepherd added a comment -

        I've been working with the new beta this morning and I am still having the same issue. First, it appears that some refactoring was done (ie AppenderBase is now AbstractAppender), but the documentation has not been updated to reflect these changes so I may be missing something. Anyway, I have updated my HappyAppender project to work with the latest beta code, all other code and my log4j xml file remained the same. When I run the HappyTest from within this project, I get the following verbose output:

        2012-12-10 10:50:34,277 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4j2Test/bin/com/log4j] matching criteria: annotated with @Plugin
        2012-12-10 10:50:34,277 DEBUG Checking to see if class com.log4j.HappyAppender matches criteria [annotated with @Plugin]
        2012-12-10 10:50:34,277 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin]
        2012-12-10 10:50:34,277 DEBUG Generated plugins in 0.005191791 seconds
        2012-12-10 10:50:34,308 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d

        {dd-MMM-yyyy (HH:mm:ss.SSS Z)}

        %-5level %message%n", Configuration(Happy Configuration), null, charset="null")
        2012-12-10 10:50:34,308 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4j2Test/bin/com/log4j] matching criteria: annotated with @Plugin is assignable to LogEventPatternConverter
        2012-12-10 10:50:34,308 DEBUG Checking to see if class com.log4j.HappyAppender matches criteria [annotated with @Plugin is assignable to LogEventPatternConverter]
        2012-12-10 10:50:34,308 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin is assignable to LogEventPatternConverter]
        2012-12-10 10:50:34,308 DEBUG Generated plugins in 0.002251892 seconds
        2012-12-10 10:50:34,308 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console with params(PatternLayout(%d

        {dd-MMM-yyyy (HH:mm:ss.SSS Z)}

        %-5level %message%n), null, target="SYSTEM_OUT", name="Console", suppressExceptions="null")
        2012-12-10 10:50:34,308 DEBUG Jansi is not installed
        2012-12-10 10:50:34,308 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%message%n", Configuration(Happy Configuration), null, charset="null")
        2012-12-10 10:50:34,308 ERROR Null object returned for Happy in appenders
        2012-12-10 10:50:34,308 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element appenders with params(appenders=

        {Console, }

        )
        2012-12-10 10:50:34,308 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4j2Test/bin/com/log4j] matching criteria: annotated with @Plugin
        2012-12-10 10:50:34,308 DEBUG Checking to see if class com.log4j.HappyAppender matches criteria [annotated with @Plugin]
        2012-12-10 10:50:34,308 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin]
        2012-12-10 10:50:34,308 DEBUG Generated plugins in 0.001830191 seconds
        2012-12-10 10:50:34,308 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="Console", level="null", null)
        2012-12-10 10:50:34,308 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element root with params(additivity="null", level="debug", appender-ref=

        {org.apache.logging.log4j.core.config.AppenderRef@1fc3eae1}

        , properties={}, Configuration(Happy Configuration), null)
        2012-12-10 10:50:34,308 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="Happy", level="null", null)
        2012-12-10 10:50:34,324 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig for element logger with params(additivity="null", level="info", name="happy.log", appender-ref=

        {org.apache.logging.log4j.core.config.AppenderRef@181ea87d}

        , properties={}, Configuration(Happy Configuration), null)
        2012-12-10 10:50:34,324 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element loggers with params(loggers=

        {root, happy.log})
        2012-12-10 10:50:34,324 ERROR Unable to locate appender Happy for logger happy.log
        2012-12-10 10:50:34,324 DEBUG Reconfiguration completed
        10-Dec-2012 (10:50:34.324 -0500) INFO I'm so happy!

        As before, when executed from within the same project, log4j scans the classes as expected, but is unable to create the HappyAppender.

        I then exported HappyAppender to a jar and copied it to the same directory as the log4j beta 3 jars. I then added it to the project path of my RFT test project and attempted to run the same HappyTest code, which gave the following output:

        2012-12-10 10:55:18,924 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4jRftTest/com/log4j] matching criteria: annotated with @Plugin
        2012-12-10 10:55:18,940 DEBUG Checking to see if class com.log4j.HappyScript matches criteria [annotated with @Plugin]
        2012-12-10 10:55:18,940 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin]
        2012-12-10 10:55:18,940 DEBUG Generated plugins in 0.015682859 seconds
        2012-12-10 10:55:18,955 ERROR Error processing element Happy: CLASS_NOT_FOUND
        2012-12-10 10:55:18,971 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d{dd-MMM-yyyy (HH:mm:ss.SSS Z)} %-5level %message%n", Configuration(Happy Configuration), null, charset="null")
        2012-12-10 10:55:18,971 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4jRftTest/com/log4j] matching criteria: annotated with @Plugin is assignable to LogEventPatternConverter
        2012-12-10 10:55:18,971 DEBUG Checking to see if class com.log4j.HappyScript matches criteria [annotated with @Plugin is assignable to LogEventPatternConverter]
        2012-12-10 10:55:18,971 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin is assignable to LogEventPatternConverter]
        2012-12-10 10:55:18,971 DEBUG Generated plugins in 0.002187708 seconds
        2012-12-10 10:55:18,971 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console with params(PatternLayout(%d{dd-MMM-yyyy (HH:mm:ss.SSS Z)} %-5level %message%n), null, target="SYSTEM_OUT", name="Console", suppressExceptions="null")
        2012-12-10 10:55:18,971 DEBUG Jansi is not installed
        2012-12-10 10:55:18,971 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element appenders with params(appenders={Console})
        2012-12-10 10:55:18,971 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4jRftTest/com/log4j] matching criteria: annotated with @Plugin
        2012-12-10 10:55:18,971 DEBUG Checking to see if class com.log4j.HappyScript matches criteria [annotated with @Plugin]
        2012-12-10 10:55:18,971 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin]
        2012-12-10 10:55:18,971 DEBUG Generated plugins in 0.002113816 seconds
        2012-12-10 10:55:18,971 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="Console", level="null", null)
        2012-12-10 10:55:18,971 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element root with params(additivity="null", level="debug", appender-ref={org.apache.logging.log4j.core.config.AppenderRef@280882b8}, properties={}, Configuration(Happy Configuration), null)
        2012-12-10 10:55:18,986 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="Happy", level="null", null)
        2012-12-10 10:55:18,986 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig for element logger with params(additivity="null", level="info", name="happy.log", appender-ref={org.apache.logging.log4j.core.config.AppenderRef@677eb214}, properties={}, Configuration(Happy Configuration), null)
        2012-12-10 10:55:18,986 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element loggers with params(loggers={root, happy.log}

        )
        2012-12-10 10:55:18,986 ERROR Unable to locate appender Happy for logger happy.log
        2012-12-10 10:55:18,986 DEBUG Reconfiguration completed
        10-Dec-2012 (10:55:18.986 -0500) INFO I'm so happy!

        So it looks like either I am doing something wrong or something still is not working.

        Show
        Aaron Shepherd added a comment - I've been working with the new beta this morning and I am still having the same issue. First, it appears that some refactoring was done (ie AppenderBase is now AbstractAppender), but the documentation has not been updated to reflect these changes so I may be missing something. Anyway, I have updated my HappyAppender project to work with the latest beta code, all other code and my log4j xml file remained the same. When I run the HappyTest from within this project, I get the following verbose output: 2012-12-10 10:50:34,277 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4j2Test/bin/com/log4j] matching criteria: annotated with @Plugin 2012-12-10 10:50:34,277 DEBUG Checking to see if class com.log4j.HappyAppender matches criteria [annotated with @Plugin] 2012-12-10 10:50:34,277 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin] 2012-12-10 10:50:34,277 DEBUG Generated plugins in 0.005191791 seconds 2012-12-10 10:50:34,308 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d {dd-MMM-yyyy (HH:mm:ss.SSS Z)} %-5level %message%n", Configuration(Happy Configuration), null, charset="null") 2012-12-10 10:50:34,308 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4j2Test/bin/com/log4j] matching criteria: annotated with @Plugin is assignable to LogEventPatternConverter 2012-12-10 10:50:34,308 DEBUG Checking to see if class com.log4j.HappyAppender matches criteria [annotated with @Plugin is assignable to LogEventPatternConverter] 2012-12-10 10:50:34,308 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin is assignable to LogEventPatternConverter] 2012-12-10 10:50:34,308 DEBUG Generated plugins in 0.002251892 seconds 2012-12-10 10:50:34,308 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console with params(PatternLayout(%d {dd-MMM-yyyy (HH:mm:ss.SSS Z)} %-5level %message%n), null, target="SYSTEM_OUT", name="Console", suppressExceptions="null") 2012-12-10 10:50:34,308 DEBUG Jansi is not installed 2012-12-10 10:50:34,308 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%message%n", Configuration(Happy Configuration), null, charset="null") 2012-12-10 10:50:34,308 ERROR Null object returned for Happy in appenders 2012-12-10 10:50:34,308 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element appenders with params(appenders= {Console, } ) 2012-12-10 10:50:34,308 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4j2Test/bin/com/log4j] matching criteria: annotated with @Plugin 2012-12-10 10:50:34,308 DEBUG Checking to see if class com.log4j.HappyAppender matches criteria [annotated with @Plugin] 2012-12-10 10:50:34,308 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin] 2012-12-10 10:50:34,308 DEBUG Generated plugins in 0.001830191 seconds 2012-12-10 10:50:34,308 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="Console", level="null", null) 2012-12-10 10:50:34,308 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element root with params(additivity="null", level="debug", appender-ref= {org.apache.logging.log4j.core.config.AppenderRef@1fc3eae1} , properties={}, Configuration(Happy Configuration), null) 2012-12-10 10:50:34,308 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="Happy", level="null", null) 2012-12-10 10:50:34,324 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig for element logger with params(additivity="null", level="info", name="happy.log", appender-ref= {org.apache.logging.log4j.core.config.AppenderRef@181ea87d} , properties={}, Configuration(Happy Configuration), null) 2012-12-10 10:50:34,324 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element loggers with params(loggers= {root, happy.log}) 2012-12-10 10:50:34,324 ERROR Unable to locate appender Happy for logger happy.log 2012-12-10 10:50:34,324 DEBUG Reconfiguration completed 10-Dec-2012 (10:50:34.324 -0500) INFO I'm so happy! As before, when executed from within the same project, log4j scans the classes as expected, but is unable to create the HappyAppender. I then exported HappyAppender to a jar and copied it to the same directory as the log4j beta 3 jars. I then added it to the project path of my RFT test project and attempted to run the same HappyTest code, which gave the following output: 2012-12-10 10:55:18,924 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4jRftTest/com/log4j] matching criteria: annotated with @Plugin 2012-12-10 10:55:18,940 DEBUG Checking to see if class com.log4j.HappyScript matches criteria [annotated with @Plugin] 2012-12-10 10:55:18,940 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin] 2012-12-10 10:55:18,940 DEBUG Generated plugins in 0.015682859 seconds 2012-12-10 10:55:18,955 ERROR Error processing element Happy: CLASS_NOT_FOUND 2012-12-10 10:55:18,971 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d{dd-MMM-yyyy (HH:mm:ss.SSS Z)} %-5level %message%n", Configuration(Happy Configuration), null, charset="null") 2012-12-10 10:55:18,971 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4jRftTest/com/log4j] matching criteria: annotated with @Plugin is assignable to LogEventPatternConverter 2012-12-10 10:55:18,971 DEBUG Checking to see if class com.log4j.HappyScript matches criteria [annotated with @Plugin is assignable to LogEventPatternConverter] 2012-12-10 10:55:18,971 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin is assignable to LogEventPatternConverter] 2012-12-10 10:55:18,971 DEBUG Generated plugins in 0.002187708 seconds 2012-12-10 10:55:18,971 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console with params(PatternLayout(%d{dd-MMM-yyyy (HH:mm:ss.SSS Z)} %-5level %message%n), null, target="SYSTEM_OUT", name="Console", suppressExceptions="null") 2012-12-10 10:55:18,971 DEBUG Jansi is not installed 2012-12-10 10:55:18,971 DEBUG Calling createAppenders on class org.apache.logging.log4j.core.config.plugins.AppendersPlugin for element appenders with params(appenders={Console}) 2012-12-10 10:55:18,971 INFO Scanning for classes in [/C:/Users/Automation/IBM/rationalsdp/workspace/Log4jRftTest/com/log4j] matching criteria: annotated with @Plugin 2012-12-10 10:55:18,971 DEBUG Checking to see if class com.log4j.HappyScript matches criteria [annotated with @Plugin] 2012-12-10 10:55:18,971 DEBUG Checking to see if class com.log4j.HappyTest matches criteria [annotated with @Plugin] 2012-12-10 10:55:18,971 DEBUG Generated plugins in 0.002113816 seconds 2012-12-10 10:55:18,971 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="Console", level="null", null) 2012-12-10 10:55:18,971 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig$RootLogger for element root with params(additivity="null", level="debug", appender-ref={org.apache.logging.log4j.core.config.AppenderRef@280882b8}, properties={}, Configuration(Happy Configuration), null) 2012-12-10 10:55:18,986 DEBUG Calling createAppenderRef on class org.apache.logging.log4j.core.config.AppenderRef for element appender-ref with params(ref="Happy", level="null", null) 2012-12-10 10:55:18,986 DEBUG Calling createLogger on class org.apache.logging.log4j.core.config.LoggerConfig for element logger with params(additivity="null", level="info", name="happy.log", appender-ref={org.apache.logging.log4j.core.config.AppenderRef@677eb214}, properties={}, Configuration(Happy Configuration), null) 2012-12-10 10:55:18,986 DEBUG Calling createLoggers on class org.apache.logging.log4j.core.config.plugins.LoggersPlugin for element loggers with params(loggers={root, happy.log} ) 2012-12-10 10:55:18,986 ERROR Unable to locate appender Happy for logger happy.log 2012-12-10 10:55:18,986 DEBUG Reconfiguration completed 10-Dec-2012 (10:55:18.986 -0500) INFO I'm so happy! So it looks like either I am doing something wrong or something still is not working.
        Hide
        Robert Breunung added a comment -

        Answering my last comment: By providing the package to the PluginManager, Log4J2 found my Appender and logged as expected messages.

        Show
        Robert Breunung added a comment - Answering my last comment: By providing the package to the PluginManager, Log4J2 found my Appender and logged as expected messages.
        Hide
        Gary Gregory added a comment -

        "First, it appears that some refactoring was done (ie AppenderBase is now AbstractAppender), but the documentation has not been updated to reflect these changes"

        I've updated the docs in SVN.

        Show
        Gary Gregory added a comment - "First, it appears that some refactoring was done (ie AppenderBase is now AbstractAppender), but the documentation has not been updated to reflect these changes" I've updated the docs in SVN.
        Hide
        Aaron Shepherd added a comment -

        Thanks Gary. Also, I went back and realized that I was missing the PluginFactory annotation on the method for creating the appender. Once I did that my appender worked as expected when used from the appender java project. However, I am still having issues in the following scenarios:

        Scenario 1: Exporting the appender to a jar and adding that jar to the build path of another project.

        In this scenario, HappyTest scanned for plugins as expected, but only looked in the packages local to the project, not in any similarly named packages which are on the class path. As such, the custom appender was not found and could not be created. As before the jar containing the custom appender is in the same directory as all of the log4j jars.

        Scenario 2: Creating a custom appender within a Rational Functional Tester project.

        In this scenario, the script did not even scan the specified package and the appender was not found. This is the same behavior as before.

        Show
        Aaron Shepherd added a comment - Thanks Gary. Also, I went back and realized that I was missing the PluginFactory annotation on the method for creating the appender. Once I did that my appender worked as expected when used from the appender java project. However, I am still having issues in the following scenarios: Scenario 1: Exporting the appender to a jar and adding that jar to the build path of another project. In this scenario, HappyTest scanned for plugins as expected, but only looked in the packages local to the project, not in any similarly named packages which are on the class path. As such, the custom appender was not found and could not be created. As before the jar containing the custom appender is in the same directory as all of the log4j jars. Scenario 2: Creating a custom appender within a Rational Functional Tester project. In this scenario, the script did not even scan the specified package and the appender was not found. This is the same behavior as before.
        Hide
        Thomas GT1 added a comment -

        i solved it adding following code block in starting class of my program

        static

        { PluginManager.addPackage("the.package.with.my.appender"); }

        Why not using

        <MyAppender name="myAppender" class="the.package.with.my.appender.MyAppender">
        </MyAppender>

        like in log4j 1.x?

        Show
        Thomas GT1 added a comment - i solved it adding following code block in starting class of my program static { PluginManager.addPackage("the.package.with.my.appender"); } Why not using <MyAppender name="myAppender" class="the.package.with.my.appender.MyAppender"> </MyAppender> like in log4j 1.x?
        Hide
        Ralph Goers added a comment -

        Using plugins makes it easier to create arbitrary subcomponents for Appenders, Filters, etc. as those classes do not have to worry about dealing with managing the creating of their subordinate objects. In addition, if frees end users from having to do things like <property name="" class="org.apache.logging.core.config.Property">value</Property>, etc. all over the place and thus either making typos or having to remember class names they don't really care about.

        What problem were you encountering that required you to add the above? Are you also using the Rational Functional Tester project?

        Show
        Ralph Goers added a comment - Using plugins makes it easier to create arbitrary subcomponents for Appenders, Filters, etc. as those classes do not have to worry about dealing with managing the creating of their subordinate objects. In addition, if frees end users from having to do things like <property name="" class="org.apache.logging.core.config.Property">value</Property>, etc. all over the place and thus either making typos or having to remember class names they don't really care about. What problem were you encountering that required you to add the above? Are you also using the Rational Functional Tester project?
        Hide
        Thomas GT1 added a comment -

        the message is:

        ERROR StatusLogger Error processing element CustomRollingFile: CLASS_NOT_FOUND

        i'm just using a simple eclipse java project with a testing class with main and a custom appender.
        including the beta-3.jar in classpath.

        Show
        Thomas GT1 added a comment - the message is: ERROR StatusLogger Error processing element CustomRollingFile: CLASS_NOT_FOUND i'm just using a simple eclipse java project with a testing class with main and a custom appender. including the beta-3.jar in classpath.
        Hide
        Remko Popma added a comment -

        Thomas,
        I had the same problem. Log4j has a plugin manager that reads plugin configuration from a file called "Log4j2Plugins.dat" in package "org.apache.logging.log4j.core.config.plugins" in the classpath. This file is in binary format.

        You can generate this file by running org.apache.logging.log4j.core.config.plugins.PluginManager as an application with two parameters:
        the first one is the output directory, the second parameter is the name of the package where your plugin lives.

        PluginManager will generate the file org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat inside the output directory you specified.
        Move that file inside the project that has your plugin (make sure it stays in the org.apache.logging.log4j.core.config.plugins package),
        and try again.

        Show
        Remko Popma added a comment - Thomas, I had the same problem. Log4j has a plugin manager that reads plugin configuration from a file called "Log4j2Plugins.dat" in package "org.apache.logging.log4j.core.config.plugins" in the classpath. This file is in binary format. You can generate this file by running org.apache.logging.log4j.core.config.plugins.PluginManager as an application with two parameters: the first one is the output directory, the second parameter is the name of the package where your plugin lives. PluginManager will generate the file org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat inside the output directory you specified. Move that file inside the project that has your plugin (make sure it stays in the org.apache.logging.log4j.core.config.plugins package), and try again.

          People

          • Assignee:
            Ralph Goers
            Reporter:
            Robert Breunung
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development