Re: Custom ConfigurationFactory not loaded
My issue came from the the way I ran my application and the fact that lo4j2 use an annotation processor. I'm running my application (and my tests) from eclipse. So I have to - Enable the option Enable annotation processing (Java Compiler - Annotation Processing) - Add log4j-core.jar in the Factory Path (Java Compiler - Annotation Processing - Factory Path) I think everything is working fine now! Thank you everyone! Clément On Sat, Aug 2, 2014 at 5:50 AM, Ralph Goers rgo...@apache.org wrote: It should work if the annotation processor is being invoked. See if your application is having a Log4j2Plugins.dat file being generated and included in your jar. Sent from my iPad On Aug 1, 2014, at 1:06 PM, Clément Guillaume cguilla...@hotpads.com wrote: PluginManager.addPackage(“com.myorg.mypackage”) works with trunk ! But for me it is almost the same as setting the system property. I would love that it automatically find my ConfigurationFactory. Is it a bug? Clément On Fri, Aug 1, 2014 at 11:02 AM, Remko Popma remko.po...@gmail.com wrote: The packages attribute in configuration (and the corresponding PluginManager.addPackage method) does not work in 2.0. This has been fixed in trunk and the fix will be in the upcoming 2.0.1 release. Can you try with trunk? On Sat, Aug 2, 2014 at 2:05 AM, Clément Guillaume cguilla...@hotpads.com wrote: The fact is that the method getSupportedTypes() is never called ! (It's return a custom extension: .myorg) I'm using 2.0. And even a call to PluginManager.addPackage(“com.myorg.mypackage”) doesn't works. Clément On Thu, Jul 31, 2014 at 10:31 PM, Ralph Goers ralph.go...@dslextreme.com wrote: It also occurs to me that the plugin manager may not be finding the plugin. If you are using 2.0 then I believe the annotation processor should register the factory as a plugin automatically. If you are using an older release you might have been required to call PluginManager.addPackage(“com.myorg.mypackage”) to have the plugin manager search for your plugin. Ralph On Jul 31, 2014, at 10:26 PM, Ralph Goers ralph.go...@dslextreme.com wrote: Your annotations are correct. However, in the code snippet below you don’t show what getSupportedTypes() returns. The generic ConfigurationFactory inspects all the ConfigurationFactory plugins using the order to determine which should be inspected first, second, etc. It calls getSupportedTypes to find out what file extensions the ConfigurationFactory handles. If the provided configuration file matches one of the file extensions than that factory will be used. “*” is used as a wildcard to specify that it handles any file extension (which is what the XMLConfigurationFactory does). However, with an Order of 10 if you specified a “*” I believe your factory would have to handle XML, JSON and YAML configurations. I would suggest having getSupportedTypes return something like “.cfg” and then having your configuration files end with .cfg. Ralph On Jul 31, 2014, at 6:18 PM, Clément Guillaume cguilla...@hotpads.com wrote: Hi, I'm trying to use a custom ConfigurationFactory. I created and annotated it with a @Plugin and an @Order like this: @Plugin(category = ConfigurationFactory, name = StartupConfigurationFactory) @Order(10) public class StartupConfigurationFactory extends ConfigurationFactory{ ... } But it is never loaded (none of the 2 methods are called). If I specify the system property log4j.configurationFactory with the name of my class before creating a logger, my factory is successfully loaded. Did I made a mistake declaring my ConfigurationFactory ? Clément - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Custom ConfigurationFactory not loaded
It should work if the annotation processor is being invoked. See if your application is having a Log4j2Plugins.dat file being generated and included in your jar. Sent from my iPad On Aug 1, 2014, at 1:06 PM, Clément Guillaume cguilla...@hotpads.com wrote: PluginManager.addPackage(“com.myorg.mypackage”) works with trunk ! But for me it is almost the same as setting the system property. I would love that it automatically find my ConfigurationFactory. Is it a bug? Clément On Fri, Aug 1, 2014 at 11:02 AM, Remko Popma remko.po...@gmail.com wrote: The packages attribute in configuration (and the corresponding PluginManager.addPackage method) does not work in 2.0. This has been fixed in trunk and the fix will be in the upcoming 2.0.1 release. Can you try with trunk? On Sat, Aug 2, 2014 at 2:05 AM, Clément Guillaume cguilla...@hotpads.com wrote: The fact is that the method getSupportedTypes() is never called ! (It's return a custom extension: .myorg) I'm using 2.0. And even a call to PluginManager.addPackage(“com.myorg.mypackage”) doesn't works. Clément On Thu, Jul 31, 2014 at 10:31 PM, Ralph Goers ralph.go...@dslextreme.com wrote: It also occurs to me that the plugin manager may not be finding the plugin. If you are using 2.0 then I believe the annotation processor should register the factory as a plugin automatically. If you are using an older release you might have been required to call PluginManager.addPackage(“com.myorg.mypackage”) to have the plugin manager search for your plugin. Ralph On Jul 31, 2014, at 10:26 PM, Ralph Goers ralph.go...@dslextreme.com wrote: Your annotations are correct. However, in the code snippet below you don’t show what getSupportedTypes() returns. The generic ConfigurationFactory inspects all the ConfigurationFactory plugins using the order to determine which should be inspected first, second, etc. It calls getSupportedTypes to find out what file extensions the ConfigurationFactory handles. If the provided configuration file matches one of the file extensions than that factory will be used. “*” is used as a wildcard to specify that it handles any file extension (which is what the XMLConfigurationFactory does). However, with an Order of 10 if you specified a “*” I believe your factory would have to handle XML, JSON and YAML configurations. I would suggest having getSupportedTypes return something like “.cfg” and then having your configuration files end with .cfg. Ralph On Jul 31, 2014, at 6:18 PM, Clément Guillaume cguilla...@hotpads.com wrote: Hi, I'm trying to use a custom ConfigurationFactory. I created and annotated it with a @Plugin and an @Order like this: @Plugin(category = ConfigurationFactory, name = StartupConfigurationFactory) @Order(10) public class StartupConfigurationFactory extends ConfigurationFactory{ ... } But it is never loaded (none of the 2 methods are called). If I specify the system property log4j.configurationFactory with the name of my class before creating a logger, my factory is successfully loaded. Did I made a mistake declaring my ConfigurationFactory ? Clément - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Custom ConfigurationFactory not loaded
The fact is that the method getSupportedTypes() is never called ! (It's return a custom extension: .myorg) I'm using 2.0. And even a call to PluginManager.addPackage(“com.myorg.mypackage”) doesn't works. Clément On Thu, Jul 31, 2014 at 10:31 PM, Ralph Goers ralph.go...@dslextreme.com wrote: It also occurs to me that the plugin manager may not be finding the plugin. If you are using 2.0 then I believe the annotation processor should register the factory as a plugin automatically. If you are using an older release you might have been required to call PluginManager.addPackage(“com.myorg.mypackage”) to have the plugin manager search for your plugin. Ralph On Jul 31, 2014, at 10:26 PM, Ralph Goers ralph.go...@dslextreme.com wrote: Your annotations are correct. However, in the code snippet below you don’t show what getSupportedTypes() returns. The generic ConfigurationFactory inspects all the ConfigurationFactory plugins using the order to determine which should be inspected first, second, etc. It calls getSupportedTypes to find out what file extensions the ConfigurationFactory handles. If the provided configuration file matches one of the file extensions than that factory will be used. “*” is used as a wildcard to specify that it handles any file extension (which is what the XMLConfigurationFactory does). However, with an Order of 10 if you specified a “*” I believe your factory would have to handle XML, JSON and YAML configurations. I would suggest having getSupportedTypes return something like “.cfg” and then having your configuration files end with .cfg. Ralph On Jul 31, 2014, at 6:18 PM, Clément Guillaume cguilla...@hotpads.com wrote: Hi, I'm trying to use a custom ConfigurationFactory. I created and annotated it with a @Plugin and an @Order like this: @Plugin(category = ConfigurationFactory, name = StartupConfigurationFactory) @Order(10) public class StartupConfigurationFactory extends ConfigurationFactory{ ... } But it is never loaded (none of the 2 methods are called). If I specify the system property log4j.configurationFactory with the name of my class before creating a logger, my factory is successfully loaded. Did I made a mistake declaring my ConfigurationFactory ? Clément - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Custom ConfigurationFactory not loaded
The packages attribute in configuration (and the corresponding PluginManager.addPackage method) does not work in 2.0. This has been fixed in trunk and the fix will be in the upcoming 2.0.1 release. Can you try with trunk? On Sat, Aug 2, 2014 at 2:05 AM, Clément Guillaume cguilla...@hotpads.com wrote: The fact is that the method getSupportedTypes() is never called ! (It's return a custom extension: .myorg) I'm using 2.0. And even a call to PluginManager.addPackage(“com.myorg.mypackage”) doesn't works. Clément On Thu, Jul 31, 2014 at 10:31 PM, Ralph Goers ralph.go...@dslextreme.com wrote: It also occurs to me that the plugin manager may not be finding the plugin. If you are using 2.0 then I believe the annotation processor should register the factory as a plugin automatically. If you are using an older release you might have been required to call PluginManager.addPackage(“com.myorg.mypackage”) to have the plugin manager search for your plugin. Ralph On Jul 31, 2014, at 10:26 PM, Ralph Goers ralph.go...@dslextreme.com wrote: Your annotations are correct. However, in the code snippet below you don’t show what getSupportedTypes() returns. The generic ConfigurationFactory inspects all the ConfigurationFactory plugins using the order to determine which should be inspected first, second, etc. It calls getSupportedTypes to find out what file extensions the ConfigurationFactory handles. If the provided configuration file matches one of the file extensions than that factory will be used. “*” is used as a wildcard to specify that it handles any file extension (which is what the XMLConfigurationFactory does). However, with an Order of 10 if you specified a “*” I believe your factory would have to handle XML, JSON and YAML configurations. I would suggest having getSupportedTypes return something like “.cfg” and then having your configuration files end with .cfg. Ralph On Jul 31, 2014, at 6:18 PM, Clément Guillaume cguilla...@hotpads.com wrote: Hi, I'm trying to use a custom ConfigurationFactory. I created and annotated it with a @Plugin and an @Order like this: @Plugin(category = ConfigurationFactory, name = StartupConfigurationFactory) @Order(10) public class StartupConfigurationFactory extends ConfigurationFactory{ ... } But it is never loaded (none of the 2 methods are called). If I specify the system property log4j.configurationFactory with the name of my class before creating a logger, my factory is successfully loaded. Did I made a mistake declaring my ConfigurationFactory ? Clément - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Custom ConfigurationFactory not loaded
PluginManager.addPackage(“com.myorg.mypackage”) works with trunk ! But for me it is almost the same as setting the system property. I would love that it automatically find my ConfigurationFactory. Is it a bug? Clément On Fri, Aug 1, 2014 at 11:02 AM, Remko Popma remko.po...@gmail.com wrote: The packages attribute in configuration (and the corresponding PluginManager.addPackage method) does not work in 2.0. This has been fixed in trunk and the fix will be in the upcoming 2.0.1 release. Can you try with trunk? On Sat, Aug 2, 2014 at 2:05 AM, Clément Guillaume cguilla...@hotpads.com wrote: The fact is that the method getSupportedTypes() is never called ! (It's return a custom extension: .myorg) I'm using 2.0. And even a call to PluginManager.addPackage(“com.myorg.mypackage”) doesn't works. Clément On Thu, Jul 31, 2014 at 10:31 PM, Ralph Goers ralph.go...@dslextreme.com wrote: It also occurs to me that the plugin manager may not be finding the plugin. If you are using 2.0 then I believe the annotation processor should register the factory as a plugin automatically. If you are using an older release you might have been required to call PluginManager.addPackage(“com.myorg.mypackage”) to have the plugin manager search for your plugin. Ralph On Jul 31, 2014, at 10:26 PM, Ralph Goers ralph.go...@dslextreme.com wrote: Your annotations are correct. However, in the code snippet below you don’t show what getSupportedTypes() returns. The generic ConfigurationFactory inspects all the ConfigurationFactory plugins using the order to determine which should be inspected first, second, etc. It calls getSupportedTypes to find out what file extensions the ConfigurationFactory handles. If the provided configuration file matches one of the file extensions than that factory will be used. “*” is used as a wildcard to specify that it handles any file extension (which is what the XMLConfigurationFactory does). However, with an Order of 10 if you specified a “*” I believe your factory would have to handle XML, JSON and YAML configurations. I would suggest having getSupportedTypes return something like “.cfg” and then having your configuration files end with .cfg. Ralph On Jul 31, 2014, at 6:18 PM, Clément Guillaume cguilla...@hotpads.com wrote: Hi, I'm trying to use a custom ConfigurationFactory. I created and annotated it with a @Plugin and an @Order like this: @Plugin(category = ConfigurationFactory, name = StartupConfigurationFactory) @Order(10) public class StartupConfigurationFactory extends ConfigurationFactory{ ... } But it is never loaded (none of the 2 methods are called). If I specify the system property log4j.configurationFactory with the name of my class before creating a logger, my factory is successfully loaded. Did I made a mistake declaring my ConfigurationFactory ? Clément - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Custom ConfigurationFactory not loaded
The configuration factory is responsible for parsing a config file and creating a Configuration object. As such, it must exist _before_ the configuration file is processed. Log4j plugins are only created during processing of the config file. So a configuration factory cannot be a plugin. Best regards, Remko Sent from my iPhone On 2014/08/01, at 10:18, Clément Guillaume cguilla...@hotpads.com wrote: Hi, I'm trying to use a custom ConfigurationFactory. I created and annotated it with a @Plugin and an @Order like this: @Plugin(category = ConfigurationFactory, name = StartupConfigurationFactory) @Order(10) public class StartupConfigurationFactory extends ConfigurationFactory{ ... } But it is never loaded (none of the 2 methods are called). If I specify the system property log4j.configurationFactory with the name of my class before creating a logger, my factory is successfully loaded. Did I made a mistake declaring my ConfigurationFactory ? Clément - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Custom ConfigurationFactory not loaded
Oh ! I did this because of the documentation available here: http://logging.apache.org/log4j/2.x/manual/extending.html#ConfigurationFactory The second method is by defining the ConfigurationFactory as a Plugin. And why all others ConfigurationFactories are declared as @Plugin ? @Plugin(name = JsonConfigurationFactory, category = ConfigurationFactory) @Order(6) public class JsonConfigurationFactory extends ConfigurationFactory { And what should be the proper way to have a custom Configuration based on a custom file format ? Regards, Clément On Thu, Jul 31, 2014 at 7:04 PM, Remko Popma remko.po...@gmail.com wrote: The configuration factory is responsible for parsing a config file and creating a Configuration object. As such, it must exist _before_ the configuration file is processed. Log4j plugins are only created during processing of the config file. So a configuration factory cannot be a plugin. Best regards, Remko Sent from my iPhone On 2014/08/01, at 10:18, Clément Guillaume cguilla...@hotpads.com wrote: Hi, I'm trying to use a custom ConfigurationFactory. I created and annotated it with a @Plugin and an @Order like this: @Plugin(category = ConfigurationFactory, name = StartupConfigurationFactory) @Order(10) public class StartupConfigurationFactory extends ConfigurationFactory{ ... } But it is never loaded (none of the 2 methods are called). If I specify the system property log4j.configurationFactory with the name of my class before creating a logger, my factory is successfully loaded. Did I made a mistake declaring my ConfigurationFactory ? Clément - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Custom ConfigurationFactory not loaded
I think you may still need to set the system property (or equivalent properties file) to override the default ConfigurationFactory. On 31 July 2014 21:34, Clément Guillaume cguilla...@hotpads.com wrote: Oh ! I did this because of the documentation available here: http://logging.apache.org/log4j/2.x/manual/extending.html#ConfigurationFactory The second method is by defining the ConfigurationFactory as a Plugin. And why all others ConfigurationFactories are declared as @Plugin ? @Plugin(name = JsonConfigurationFactory, category = ConfigurationFactory) @Order(6) public class JsonConfigurationFactory extends ConfigurationFactory { And what should be the proper way to have a custom Configuration based on a custom file format ? Regards, Clément On Thu, Jul 31, 2014 at 7:04 PM, Remko Popma remko.po...@gmail.com wrote: The configuration factory is responsible for parsing a config file and creating a Configuration object. As such, it must exist _before_ the configuration file is processed. Log4j plugins are only created during processing of the config file. So a configuration factory cannot be a plugin. Best regards, Remko Sent from my iPhone On 2014/08/01, at 10:18, Clément Guillaume cguilla...@hotpads.com wrote: Hi, I'm trying to use a custom ConfigurationFactory. I created and annotated it with a @Plugin and an @Order like this: @Plugin(category = ConfigurationFactory, name = StartupConfigurationFactory) @Order(10) public class StartupConfigurationFactory extends ConfigurationFactory{ ... } But it is never loaded (none of the 2 methods are called). If I specify the system property log4j.configurationFactory with the name of my class before creating a logger, my factory is successfully loaded. Did I made a mistake declaring my ConfigurationFactory ? Clément - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org -- Matt Sicker boa...@gmail.com
Re: Custom ConfigurationFactory not loaded
What is the equivalent properties file, considering that I use a custom file format and a custom parser ? Clément On Thu, Jul 31, 2014 at 7:37 PM, Matt Sicker boa...@gmail.com wrote: I think you may still need to set the system property (or equivalent properties file) to override the default ConfigurationFactory. On 31 July 2014 21:34, Clément Guillaume cguilla...@hotpads.com wrote: Oh ! I did this because of the documentation available here: http://logging.apache.org/log4j/2.x/manual/extending.html#ConfigurationFactory The second method is by defining the ConfigurationFactory as a Plugin. And why all others ConfigurationFactories are declared as @Plugin ? @Plugin(name = JsonConfigurationFactory, category = ConfigurationFactory) @Order(6) public class JsonConfigurationFactory extends ConfigurationFactory { And what should be the proper way to have a custom Configuration based on a custom file format ? Regards, Clément On Thu, Jul 31, 2014 at 7:04 PM, Remko Popma remko.po...@gmail.com wrote: The configuration factory is responsible for parsing a config file and creating a Configuration object. As such, it must exist _before_ the configuration file is processed. Log4j plugins are only created during processing of the config file. So a configuration factory cannot be a plugin. Best regards, Remko Sent from my iPhone On 2014/08/01, at 10:18, Clément Guillaume cguilla...@hotpads.com wrote: Hi, I'm trying to use a custom ConfigurationFactory. I created and annotated it with a @Plugin and an @Order like this: @Plugin(category = ConfigurationFactory, name = StartupConfigurationFactory) @Order(10) public class StartupConfigurationFactory extends ConfigurationFactory{ ... } But it is never loaded (none of the 2 methods are called). If I specify the system property log4j.configurationFactory with the name of my class before creating a logger, my factory is successfully loaded. Did I made a mistake declaring my ConfigurationFactory ? Clément - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org -- Matt Sicker boa...@gmail.com
Re: Custom ConfigurationFactory not loaded
The property is named log4j.configurationFactory. How are you building your custom ConfigurationFactory? If you're using an IDE, you'll have to enable annotation processing in your settings. Otherwise, you'll have to override it with the system property. On 31 July 2014 22:30, Clément Guillaume cguilla...@hotpads.com wrote: What is the equivalent properties file, considering that I use a custom file format and a custom parser ? Clément On Thu, Jul 31, 2014 at 7:37 PM, Matt Sicker boa...@gmail.com wrote: I think you may still need to set the system property (or equivalent properties file) to override the default ConfigurationFactory. On 31 July 2014 21:34, Clément Guillaume cguilla...@hotpads.com wrote: Oh ! I did this because of the documentation available here: http://logging.apache.org/log4j/2.x/manual/extending.html#ConfigurationFactory The second method is by defining the ConfigurationFactory as a Plugin. And why all others ConfigurationFactories are declared as @Plugin ? @Plugin(name = JsonConfigurationFactory, category = ConfigurationFactory) @Order(6) public class JsonConfigurationFactory extends ConfigurationFactory { And what should be the proper way to have a custom Configuration based on a custom file format ? Regards, Clément On Thu, Jul 31, 2014 at 7:04 PM, Remko Popma remko.po...@gmail.com wrote: The configuration factory is responsible for parsing a config file and creating a Configuration object. As such, it must exist _before_ the configuration file is processed. Log4j plugins are only created during processing of the config file. So a configuration factory cannot be a plugin. Best regards, Remko Sent from my iPhone On 2014/08/01, at 10:18, Clément Guillaume cguilla...@hotpads.com wrote: Hi, I'm trying to use a custom ConfigurationFactory. I created and annotated it with a @Plugin and an @Order like this: @Plugin(category = ConfigurationFactory, name = StartupConfigurationFactory) @Order(10) public class StartupConfigurationFactory extends ConfigurationFactory{ ... } But it is never loaded (none of the 2 methods are called). If I specify the system property log4j.configurationFactory with the name of my class before creating a logger, my factory is successfully loaded. Did I made a mistake declaring my ConfigurationFactory ? Clément - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org -- Matt Sicker boa...@gmail.com -- Matt Sicker boa...@gmail.com
Re: Custom ConfigurationFactory not loaded
Matt, Your answer is incorrect. No system property needs to be set. Ralph On Jul 31, 2014, at 7:37 PM, Matt Sicker boa...@gmail.com wrote: I think you may still need to set the system property (or equivalent properties file) to override the default ConfigurationFactory. On 31 July 2014 21:34, Clément Guillaume cguilla...@hotpads.com wrote: Oh ! I did this because of the documentation available here: http://logging.apache.org/log4j/2.x/manual/extending.html#ConfigurationFactory The second method is by defining the ConfigurationFactory as a Plugin. And why all others ConfigurationFactories are declared as @Plugin ? @Plugin(name = JsonConfigurationFactory, category = ConfigurationFactory) @Order(6) public class JsonConfigurationFactory extends ConfigurationFactory { And what should be the proper way to have a custom Configuration based on a custom file format ? Regards, Clément On Thu, Jul 31, 2014 at 7:04 PM, Remko Popma remko.po...@gmail.com wrote: The configuration factory is responsible for parsing a config file and creating a Configuration object. As such, it must exist _before_ the configuration file is processed. Log4j plugins are only created during processing of the config file. So a configuration factory cannot be a plugin. Best regards, Remko Sent from my iPhone On 2014/08/01, at 10:18, Clément Guillaume cguilla...@hotpads.com wrote: Hi, I'm trying to use a custom ConfigurationFactory. I created and annotated it with a @Plugin and an @Order like this: @Plugin(category = ConfigurationFactory, name = StartupConfigurationFactory) @Order(10) public class StartupConfigurationFactory extends ConfigurationFactory{ ... } But it is never loaded (none of the 2 methods are called). If I specify the system property log4j.configurationFactory with the name of my class before creating a logger, my factory is successfully loaded. Did I made a mistake declaring my ConfigurationFactory ? Clément - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org -- Matt Sicker boa...@gmail.com - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Custom ConfigurationFactory not loaded
Remko, Your answer is incorrect. All ConfigurationFactories are annotated as plugins. Ralph On Jul 31, 2014, at 7:04 PM, Remko Popma remko.po...@gmail.com wrote: The configuration factory is responsible for parsing a config file and creating a Configuration object. As such, it must exist _before_ the configuration file is processed. Log4j plugins are only created during processing of the config file. So a configuration factory cannot be a plugin. Best regards, Remko Sent from my iPhone On 2014/08/01, at 10:18, Clément Guillaume cguilla...@hotpads.com wrote: Hi, I'm trying to use a custom ConfigurationFactory. I created and annotated it with a @Plugin and an @Order like this: @Plugin(category = ConfigurationFactory, name = StartupConfigurationFactory) @Order(10) public class StartupConfigurationFactory extends ConfigurationFactory{ ... } But it is never loaded (none of the 2 methods are called). If I specify the system property log4j.configurationFactory with the name of my class before creating a logger, my factory is successfully loaded. Did I made a mistake declaring my ConfigurationFactory ? Clément - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Custom ConfigurationFactory not loaded
Your annotations are correct. However, in the code snippet below you don’t show what getSupportedTypes() returns. The generic ConfigurationFactory inspects all the ConfigurationFactory plugins using the order to determine which should be inspected first, second, etc. It calls getSupportedTypes to find out what file extensions the ConfigurationFactory handles. If the provided configuration file matches one of the file extensions than that factory will be used. “*” is used as a wildcard to specify that it handles any file extension (which is what the XMLConfigurationFactory does). However, with an Order of 10 if you specified a “*” I believe your factory would have to handle XML, JSON and YAML configurations. I would suggest having getSupportedTypes return something like “.cfg” and then having your configuration files end with .cfg. Ralph On Jul 31, 2014, at 6:18 PM, Clément Guillaume cguilla...@hotpads.com wrote: Hi, I'm trying to use a custom ConfigurationFactory. I created and annotated it with a @Plugin and an @Order like this: @Plugin(category = ConfigurationFactory, name = StartupConfigurationFactory) @Order(10) public class StartupConfigurationFactory extends ConfigurationFactory{ ... } But it is never loaded (none of the 2 methods are called). If I specify the system property log4j.configurationFactory with the name of my class before creating a logger, my factory is successfully loaded. Did I made a mistake declaring my ConfigurationFactory ? Clément - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org
Re: Custom ConfigurationFactory not loaded
It also occurs to me that the plugin manager may not be finding the plugin. If you are using 2.0 then I believe the annotation processor should register the factory as a plugin automatically. If you are using an older release you might have been required to call PluginManager.addPackage(“com.myorg.mypackage”) to have the plugin manager search for your plugin. Ralph On Jul 31, 2014, at 10:26 PM, Ralph Goers ralph.go...@dslextreme.com wrote: Your annotations are correct. However, in the code snippet below you don’t show what getSupportedTypes() returns. The generic ConfigurationFactory inspects all the ConfigurationFactory plugins using the order to determine which should be inspected first, second, etc. It calls getSupportedTypes to find out what file extensions the ConfigurationFactory handles. If the provided configuration file matches one of the file extensions than that factory will be used. “*” is used as a wildcard to specify that it handles any file extension (which is what the XMLConfigurationFactory does). However, with an Order of 10 if you specified a “*” I believe your factory would have to handle XML, JSON and YAML configurations. I would suggest having getSupportedTypes return something like “.cfg” and then having your configuration files end with .cfg. Ralph On Jul 31, 2014, at 6:18 PM, Clément Guillaume cguilla...@hotpads.com wrote: Hi, I'm trying to use a custom ConfigurationFactory. I created and annotated it with a @Plugin and an @Order like this: @Plugin(category = ConfigurationFactory, name = StartupConfigurationFactory) @Order(10) public class StartupConfigurationFactory extends ConfigurationFactory{ ... } But it is never loaded (none of the 2 methods are called). If I specify the system property log4j.configurationFactory with the name of my class before creating a logger, my factory is successfully loaded. Did I made a mistake declaring my ConfigurationFactory ? Clément - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org